Tuesday 6 November 2007

Custom Http Handlers

The complete article
The concept of custom HTTP Handlers is not new, but is a bit overlooked one. Performance-wise, using custom HTTP Handler is an excellent choice over ASP.NET pages when you don't need the huge overhead of ViewStates, Page life cycle events and support for postback stuff etc.
Another extremely powerful, yet easily implementable use of a custom HTTP Handler is to process some resource or some type resources in your web site in special manner. E.g. You can restrict access to all *.txt file (no matter which web folder they are in) or if log.dat is requested then based upon valid role of the user, present the logged information from database etc.
In this article we'll create a HTTP Handler to resize an image as per parameters that user passes. I have used Ajax Slider control only for better UI. Then as an example of how HTTP Handler can be used to process a type of files, we would create another HTTP handler to restrict access to specific types of files types, just to get an idea of this type of application.

No comments: