Creating HttpHandlers

A synchronous HttpHandler implements the System.Web.IHttpHandler interface. An asynchronous HttpHandler implements the System.Web.IHttpAsyncHandler interface.

The System.Web.IHttpAsyncHandler interface inherits from System.Web.IHttpHandler. Both of these interfaces require you to implement the ProcessRequest method and the IsReusable property. ProcessRequest processes individual HTTP requests. IsReusable specifies whether pooling is supported.

In addition, the System.Web.IHttpAsyncHandler interface requires the implementation of the BeginProcessRequest and EndProcessRequest methods. BeginProcessRequest initiates an asynchronous call to process individual HTTP requests, and EndProcessRequest executes cleanup code when the process ends.

It is also possible to create an instance of an HttpHandler by means of a class implementing the IHttpHandlerFactory interface. This can allow finer control over the processing of an HTTP request by mapping a URL to an HttpHandler factory that creates different handlers based on a complex set of conditions. For example, with an HttpHandler factory you can create one HttpHandler for a file type if the HTTP request method is PUT, and another if the method is GET.

See Also

HTTP Runtime Support | ASP.NET Request Processing | Registering HttpHandlers | HttpModules