HttpHandlers!! What are they?

There are many features in asp.net 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 asp.net resource, like, .aspx, .ascx, etc, the asp.net 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.

Leave a Reply

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

WordPress.com Logo

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

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s