1 Answer

0 votes
by

Every request into an ASP.NET application is handled by a specialized component known as an HTTP handler. The HTTP handler is the most important ingredient while handling ASP.NET requests.

Examples: ASP.NET uses different HTTP handlers to serve different file types. For example, the handler for web Page creates the page and control objects, runs your code, and renders the final HTML.

ASP.NET default handlers,

  1. Page Handler (.aspx) - Handles Web pages.
  2. User Control Handler (.ascx) - Handles Web user control pages.
  3. Web Service Handler (.asmx) - Handles Web service pages.
  4. Trace Handler (trace.axd) - Handles trace functionality.

Why we need to create our own HTTP Handler: Sometime we need to avoid ASP.NET full page processing model, which saves lot of overheads, as ASP.NET web form model has to go through many steps such as creating web page objects, persisting view state etc. What we are interested in is to develop some low level interface that provides access to objects like Request and Response but doesn't use the full control based web form model discussed above.

Examples

  1. Dynamic image creator - Use the System.Drawing classes to draw and size your own images.
  2. RSS - Create a handler that responds with RSS-formatted XML. This would allow you to add RSS feed capabilities to your sites.
  3. Render a custom image,
  4. Perform an ad hoc database query,
  5. Return some binary data.

All HTTP handlers are defined in the <httpHandlers> section of a configuration file which is nested in the <system.web> element.

  1. <httpHandlers>  
  2.     <add verb="*" path="trace.axd" validate="true" type="System.Web.Handlers.TraceHandler" />  
  3.     <add verb="*" path="*.config" validate="true" type="System.Web.HttpForbiddenHandler" />  
  4.     <add verb="*" path="*.cs" validate="true" type="System.Web.HttpForbiddenHandler" />  
  5.     <add verb="*" path="*.aspx" validate="true" type="System.Web.UI.PageHandlerFactory

Related questions

0 votes
    What is the Tab Control in WPF?...
asked Apr 9, 2021 in Education by JackTerrance
0 votes
    What is resource in WPF? How many types of resources in WPF?...
asked Apr 9, 2021 in Education by JackTerrance
0 votes
    How can we improve the Performance of an ASP.NET Web Page?...
asked Apr 8, 2021 in Education by JackTerrance
...