Click or drag to resize

DavContextBase Constructor (HttpContext)

IT Hit WebDAV Classes Reference
Initializes context for IIS/ASP.NET based server.

Namespace: ITHit.WebDAV.Server
Assembly: ITHit.WebDAV.Server (in ITHit.WebDAV.Server.dll) Version: 4.5.3121.0
public DavContextBase(
	HttpContext context


Type: System.WebHttpContext
An ASP.NET HttpContext object.

You must create a new context in each request to your WebDAV server passing ASP.NET context.

This method instance is optimized for processing requests in IIS/ASP.NET-based server.


The code below is part of 'WebDAVServer.NtfsStorage' sample provided with the SDK.

public class DavHandler : IHttpHandler
    private readonly string license = File.ReadAllText(HttpContext.Current.Request.PhysicalApplicationPath + "License.lic");

    private static readonly bool debugLoggingEnabled =

    public bool IsReusable
        get { return true; }

    public void ProcessRequest(HttpContext context)
        DavEngine engine = getOrInitializeEngine(context);

        context.Response.BufferOutput = false;
        DavContext ntfsDavContext = new DavContext(context);

    private DavEngine initializeEngine(HttpContext context)

        ILogger logger = Logger.Instance;
        var engine = new DavEngine
            Logger = logger

            // Use idented responses if debug logging is enabled.
            , OutputXmlFormatting = debugLoggingEnabled ? Formatting.Indented : Formatting.None

        engine.License = license;

        return engine;

    private DavEngine getOrInitializeEngine(HttpContext context)
        //we don't use any double check lock pattern here because nothing wrong
        //is going to happen if we created occasionally several engines.
        const string ENGINE_KEY = "$DavEngine$";
        if (context.Application[ENGINE_KEY] == null)
            context.Application[ENGINE_KEY] = initializeEngine(context);

        return (DavEngine)context.Application[ENGINE_KEY];
See Also