Oct 27, 2015

What are http handlers in ASP.NET

HTTP handlers are the .NET components that implement the System.Web.IHttpHandler interface. Any class that implements the IHttpHandler interface can act as a target for the incoming HTTP requests. HTTP handlers are somewhat similar to ISAPI extensions. One difference between HTTP handlers and ISAPI extensions is that HTTP handlers can be called directly by using their file name in the URL, similar to ISAPI extensions. HTTP handlers implement the following methods. Method Name Description ProcessRequest This method is actually the heart of all http handlers. This method is called to process http requests. IsReusable This property is called to determine whether this instance of http handler can be reused for fulfilling another requests of the same type. HTTP handlers can return either true or false in order to specify whether they can be reused



in the simplest terms, an ASP.NET HttpHandler is a class that implements the System.Web.IHttpHandler interface. ASP.NET HTTPHandlers are responsible for intercepting requests made to your ASP.NET web application server. They run as processes in response to a request made to the ASP.NET Site. The most common handler is an ASP.NET page handler that processes .aspx files. When users request an .aspx file, the request is processed by the page through the page handler. ASP.NET offers a few default HTTP handlers: Page Handler (.aspx): handles Web pages User Control Handler (.ascx): handles Web user control pages Web Service Handler (.asmx): handles Web service pages Trace Handler (trace.axd): handles trace functionality You can create your own custom HTTP handlers that render custom output to the browser. Typical scenarios for HTTP Handlers in ASP.NET are for example delivery of dynamically created images (charts for example) or resized pictures. RSS feeds which emit RSS-formated XML You implement the IHttpHandler interface to create a synchronous handler and the IHttpAsyncHandler interface to create an asynchronous handler. The interfaces require you to implement the ProcessRequest method and the IsReusable property. The ProcessRequest method handles the actual processing for requests made, while the Boolean IsReusable property specifies whether your handler can be pooled for reuse (to increase performance) or whether a new handler is required for each request.

No comments:

Post a Comment