Creating a Custom WebDAV Method Handler
With IT Hit WebDAV Server Engine for .NET you can create a custom method handler to process any custom HTTP verbs as part of the Engine processing pipeline. The most typical verb that you would want to process in your WebDAV server that is not handled by the Engine is a GET request. In this article, we will describe how to create it.
Creating a Custom Method Handler for GET Request
When a WebDAV server is accessed using a desktop WebDAV clients such as Microsoft mini redirector/Web Folders or Mac OS X Finder, the desktop WebDAV client never submits GET request to a WebDAV folder, so if you are using desktop clients only, you do not need to care about the scenario described here.
However, a user may also access your WebDAV server by typing a URL of the WebDAV server in a web browser. In this case, you would want to display some custom web page that contains information about how to connect to your server, list folder contents, or display other information.
When a user types WebDAV server root URL or URL of some folder (such as https://myserver/somefolder/) in a web browser address bar and hits 'Go', the web browser submits a GET request to a WebDAV folder. The GET requests submitted to WebDAV folders are not regulated by WebDAV protocol and are not processed by the IT Hit WebDAV Server. To display some custom web page, you must implement a custom method handler and register it with the Engine.
To register a handler, call DavEngineAsync.RegisterMethodHandler method passing the HTTP method name and object instance implementing IMethodHandler interface. The original handler, if any, is returned from RegisterMethodHandler method. An example below processes and displays an ASP.NET web page in response to a GET request to a folder:
This code is part of WebDAV Server File System sample provided with IT Hit WebDAV Server Engine for .NET
This code is part of WebDAV Server File System sample provided with IT Hit WebDAV Server Engine for .NET
The following example lists folder content:
This code is part of WebDAV Server File System sample provided with IT Hit WebDAV Server Engine for .NET
This code is part of WebDAV Server File System sample provided with IT Hit WebDAV Server Engine for .NET