Click or drag to resize

DavContextBase Class

IT Hit WebDAV Classes Reference
Serves as the abstract base class for WebDAV context.
Inheritance Hierarchy

Namespace: ITHit.WebDAV.Server
Assembly: ITHit.WebDAV.Server (in ITHit.WebDAV.Server.dll) Version: 4.5.3121.0
public abstract class DavContextBase

The DavContextBase type exposes the following members.

Public methodCode exampleDavContextBase(HttpContext)
Initializes context for IIS/ASP.NET based server.
Public methodDavContextBase(HttpListenerContext, HttpListenerPrefixCollection)
Initializes context for HttpListener-based server.
Public methodDavContextBase(DavRequest, DavResponse)
Initializes a new instance of the WebDAV context.
Public propertyEngine
Instance of DavEngine which is currently executing the request.
Public propertyException
Exception which occurred during request execution.
Public propertyRequest
Object representing current request.
Public propertyResponse
Object representing current response.
Public methodBeforeResponse
This method is called right before engine starts writing response.
Public methodEnsureBeforeResponseWasCalled
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodCode exampleGetHierarchyItem
Implementation of this abstract method is used by WebDAV engine to find hierarchy item objects by path.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodLocalizeSatus
May be overriden to localize HTTP status message.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)

Context holds request, response and provides item factory method GetHierarchyItem(String).

When you inherit from the DavContext class, you must override GetHierarchyItem(String) method. In this method you will search for file, folder, version or history item in your storage by path provided and return it to WebDAV engine.

In each HTTP request you will create separate instance of your class derived from DavContext with one of its overloaded constructors and pass it to Run(DavContextBase).

The DavContextBase provides several overloaded constructors. They are optimized for use with OWIN, with IIS/ASP.NET-based server and in HttpListener-based server. You can also implement your own request and response classes to run the Engine in virtually any hosting environment.


HttpListener-based server:

class Program
    static void Main(string[] args)
        HttpListener listener = new HttpListener();
        DavEngine engine = new DavEngine();

        while (true)
            HttpListenerContext context = listener.GetContext();
            MacOsXPreprocessor.Process(context.Request); // fixes headers for Mac OS X v10.5.3 or later

            if (!userAutorized(context))
                context.Response.StatusCode = 401;
                showLoginDialog(context, context.Response);

            context.Response.SendChunked = false;

            var davContext = new MyDavContext(context, listener.Prefixes);

            if (context.Response.StatusCode == 401)
               showLoginDialog(context, context.Response);

Thread Safety
Instance members of this class are not thread safe. You must create a separate instance of DavContextBase class for each request.
See Also