Creating WebDAV HttpHandler

The following steps describe how to create HttpHandler and host your WebDAV server in IIS:

  1. Implement interfaces required for Class 1 server as described in Creating Class 1 WebDAV Server. Optionally you can implement Class 2, resumable upload and DeltaV support. 
  2. Create your class derived from IHttpHandler
     public class MyHttpHandler :IHttpHandler
        public void ProcessRequest(HttpContext context)
            context.Response.BufferOutput = false;
            // always create log file outside of the \bin folder if hosted in IIS\ASP.NET.
            FileLogger.LogFile = context.Request.PhysicalApplicationPath + "WebDAVlog.txt";
            WDEngine engine = new WDEngine();
    Make sure your log file is created outside of the \bin folder. If your logfile will be created in a \bin folder, your server will restart each time the logfile is updated, recycling application and session state. 
  3. Create a web application in IIS that will be the root of your WebDav server storage. Configure your web application to catch all WebDAV related verbs as described in Creating WebDAV Server Web Application in IIS
  4. Place your .dll file created in step 1 and 2 and ITHit.WebDAV.Server.dll to the \bin folder of your web application. 
  5. Place License.lic at the root of your WebDAV server. If you would like to store license in any other place read more at Reading the License
  6. Place web.config file at the root of your application. In the web.config file set your HTTP handler class created in step 2 as the only HTTP handler of your application. Clear all other handlers: 

    In the case of IIS 7.0 integrated mode: 

       <clear />
       <add name="My WebDAV Handler" path="*" verb="*" type=" MyNamespace.MyHttpHandler, MyDll" />

    In the case of IIS 7.0 classic mode, IIS 6.0 or 5.1:

       <clear />
        <add verb="*" path="*" type="MyNamespace.MyHttpHandler, MyDll" />
  7. Make sure your web application has enough permissions for creating a logfile. If any exceptions occur or the license file is not found the information will be logged to this file. Read more about logging here.

See Also: