DekGenius.com
[ Team LiB ] Previous Section Next Section

IHttpHandler

System.Web (system.web.dll)interface

This interface is required to process HTTP requests. It's implemented by the System.Web.UI.Page and HttpApplication classes, but you can use IHttpHandler to create a custom HttpHandler for a lower-level programming model. You can still access the HttpContext object (and, through its properties, built in objects like HttpRequest and HttpResponse), but you cannot use the higher-level Page abstraction. Common uses of handlers include filters and CGI-like applications, especially those returning binary data.

When using the IHttpHandler interface, you must implement the ProcessRequest( ) method and IsReusable property. The ProcessRequest( ) method receives an HttpContext object, which gives you access to ASP.NET's built-in objects. Use the IsReusable property to declare whether a single instance of your handler can serve multiple requests.

You will also need to modify <httphandlers> section of the web.config file to make your custom handler a target for HTTP requests. You can map requests based on the requested page, file type, or HTTP method (GET, PUT, or POST). If you want to create a handler that can process all requests, you should create a custom HttpModule using the IHttpModule interface.

public interface IHttpHandler {
// Public Instance Properties
   public bool IsReusable{get; }
// Public Instance Methods
   public void ProcessRequest(HttpContext context);
}

Implemented By

HttpApplication, IHttpAsyncHandler, System.Web.Services.Discovery.DiscoveryRequestHandler, System.Web.UI.Page

Returned By

HttpContext.Handler, IHttpHandlerFactory.GetHandler( ), System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler( ), System.Web.UI.PageParser.GetCompiledPageInstance( )

Passed To

HttpContext.Handler, IHttpHandlerFactory.ReleaseHandler( ), System.Web.Services.Protocols.WebServiceHandlerFactory.ReleaseHandler( )

    [ Team LiB ] Previous Section Next Section