Registers custom method handler.
Original handler if any.
Using this method you can register custom method handler to be caller by the engine. If the handler for the specified method was already defined it is returned from this method. The original handler can be saved and called later from your custom handler.
The WebDAV protocol does not regulate GET request to a WebDAV collection (folder). The following sample demonstrates custom handler for GET request submitted to folder item. The custom handler returns HTML page for folder while calling the original handler for any other items.
WDEngine engine = new WDEngine();
// set custom handler to process GET requests to folders
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);
}
}
Engine Class | ITHit.WebDAV.Server Namespace