Engine.RegisterMethodHandler Method 

IT Hit WebDAV for .NET

Registers custom method handler.

[Visual Basic]
Public Function RegisterMethodHandler( _
   ByVal method As String, _
   ByVal handler As IMethodHandler _
) As IMethodHandler
[C#]
public IMethodHandler RegisterMethodHandler(
   string method,
   IMethodHandler handler
);

Parameters

method
HTTP verb.
handler
Custom handled implementing IMethodHandler interface.

Return Value

Original handler if any.

Remarks

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.

Example

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);
    }
}
                
            

See Also

Engine Class | ITHit.WebDAV.Server Namespace