IMethodHandler Interface

IT Hit WebDAV for .NET

Represents HTTP method handler.

For a list of all members of this type, see IMethodHandler Members.

[Visual Basic]
Public Interface IMethodHandler
[C#]
public interface IMethodHandler

Remarks

The IT Hit WebDAV Server Engine allows creating custom HTTP handlers and replacing original engine handlers. To add or replace handler call RegisterMethodHandler method passing method name and object instance implementing IMethodHandler interface prior to calling Run. The original handler, if any, is returned from RegisterMethodHandler method.

The ProcessRequest method of this interface is called by the engine during Run call. The hierarchy item returned from GetHierarchyItem is passed to ProcessRequest method as a parameter.

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

Requirements

Namespace: ITHit.WebDAV.Server

Assembly: ITHit.WebDAV.Server (in ITHit.WebDAV.Server.dll)

See Also

IMethodHandler Members | ITHit.WebDAV.Server Namespace