Home
english
Home
WebDAV Server
WebDAV Client
WebDAV AJAX
Map Drive
Pricing
News
Contacts
info@ithit.com



Creating a Custom Engine Method Handler

Here are some situations when you may need a custom handler:

  • Display custom page in response to GET request sent to a folder.
  • Create image thumbnails stored in a WebDAV server.
  • Save files uploaded to server using POST verb. By default WebDAV clients upload files using PUT verb. You may need to create POST handler if you want to process files from clients that does not support PUT.
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);

    }

}


What WebDAV software would you like to have?

Selected Customers:
Country: Norway
DnB NOR Group
Country: Finland
Bank of Finland
Country: United Kingdom
Bechtle Direct
Country: Sweden
BT Industries
Country: USA
California Chamber of Commerce
Country: Denmark
Danfoss Group
Country: Denmark
DFDS
Country: USA
Fluke Networks
Country: USA
HNI Corporation
Country: USA
IHS Inc
Country: USA
LandAmerica Financial Group
Country: Canada
Laurentian University
Country: USA
Microsoft
Country: Israel
RADVISION
Country: Ukraine
Raiffeisen Bank
Country: Netherlands
Sanoma Uitgevers
Country: USA
Siemens
Country: Australia
WorkCover NSW
Country: Ukraine
OTP Bank
Country: USA
Intel Corporation
Country: Austria
Austrian Federal Railways
Home WebDAV Server WebDAV Client WebDAV AJAX Map Drive Pricing News Contacts

Updated: Thursday, March 20, 2008