What is an HttpHandler in ASP.NET? Why and how is it used?
In the simplest terms, an ASP.NET HttpHandler is a class that implements the
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:
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
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
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.