Creating a Custom Engine Method Handler
In this article
Creating a Custom Engine Method Handler
Below we will describe how to create a handler to display a custom page in response to GET request sent to a folder.
If user types WebDAV server path in a browser address bar and hits Go the browser will display 405, "Method Not Allowed" page (for Internet Explorer) or the empty page (for Firefox and Opera). The browser actually submits GET request to a WebDAV folder. The GET requests submitted to folder items are not regulated by WebDAV protocol and the Engine V1 always returned 405, "Method Not Allowed" in this case. In Engine V2, you can create a method handler and return custom HTML page.
The Engine V2 provides IMethodHandler interface that must be implemented by your custom handler and passed to Engine.RegisterMethodHandler method. The RegisterMethodHandler will return the original method handler. It can be saved and called later from your custom handler if necessary:
MyCustomGetHandler handler = new MyCustomGetHandler(); handler.OriginalHandler = engine.RegisterMethodHandler("GET", handler); engine.Run(request, response); ... class MyCustomGetHandler : IMethodHandler { private IMethodHandler originalHandler; public IMethodHandler OriginalHandler { set { originalHandler = value; } } public void ProcessRequest(Request request, IResponse response, IHierarchyItem item) { if(item is IFolder) HttpContext.Current.Response.TransmitFile(HttpContext.Current.Request.PhysicalApplicationPath + "MyCustomHandlerPage.html"); else originalHandler.ProcessRequest(request, response, item); } }