Engine.Run Method (HttpListenerContext, HttpListenerPrefixCollection)

IT Hit WebDAV for .NET

Processes WebDAV request and generates WebDAV response for HttpListener-based server.

[Visual Basic]
Overloads Public Sub Run( _
   ByVal context As HttpListenerContext, _
   ByVal prefixes As HttpListenerPrefixCollection _
)
[C#]
public void Run(
   HttpListenerContext context,
   HttpListenerPrefixCollection prefixes
);

Parameters

context
An HttpListenerContext object.
prefixes
List of HttpListener prefixes.

Remarks

You must call Run method in each request to your WebDAV server passing listener context and list of HttpListener prefixes.

This method instance is optimized for processing requests in HttpListener. If you host your server in IIS/ASP.NET use this Run overloaded instance instead.

Example

    static void Main(string[] args)
    {
        string uriPrefix = ConfigurationManager.AppSettings["ListenerPrefix"];
        HttpListener listener = new HttpListener();
        listener.Prefixes.Add(uriPrefix);
        listener.Start();
        while (true)
        {
            IAsyncResult result = listener.BeginGetContext(new AsyncCallback(ListenerCallback), listener);
            result.AsyncWaitHandle.WaitOne();
        }
    }

    public static void ListenerCallback(IAsyncResult result)
    {
        HttpListener listener = (HttpListener)result.AsyncState;
        HttpListenerContext context = listener.EndGetContext(result);
        WDEngine engine = new WDEngine(context.User);
        engine.Run(context, listener.Prefixes);
        try
        {
            context.Response.Close();
        }
        catch
        {
            // client closed connection before the content was sent
        }
    }
 

See Also

Engine Class | ITHit.WebDAV.Server Namespace | Engine.Run Overload List