HttpHandlers!! What are they?

There are many features in that are left unused, much because, developers don’t know when to use them. Such a feature is HttpHandlers.

When a request is made to IIS for an resource, like, .aspx, .ascx, etc, the worker process internally creates an instance of right HttpHandler for the request and effectively hands off the task of responding to the request. In Configuration files, paths are mapped to HttpHandlers for each kind of resource.

An HttpHandler is any class that implements System.Web.IHttpHandler interface. This interface provides a method ProcessRequest that process all the requests that are given to HttpHandlers. A quick note, PageHandlerFactory (Default Handler for .aspx) implements IPageHandlerFactory, instead of IHttpHandlers but it have a method GetHandler, which returns an instance of HttpHandler.  System.Web.UI.Page also implements this handler to process all the requests that comes to a aspx page.

Uses: Almost anything you want to do using custom HttpHandler can be done using Handler implemented in System.Web.UI.Page. But sometimes you may not want to fire all the events associated with a Page method, so you can use custom Handlers.

No Use: HttpHandlers can be used to handle extensions specified in IIS only.


Published by

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: