I just want to know what is exact job of HTTPModule & HTTPHandler in .NET.
What they actually does ?
When they actually be called ?
Dont want just the definition, want to know the exact purpose of it.
Any real time examples will be appreciated.
Loading

Jean PaulPosted Oct 6, 2010, 5:21 AM
We can implement HTTP Modules by creating a class implementing the IHttpModule interface and later plugging in the class to the web.config of the web site. In our class we can intercept or change the requests incoming. From a developer perspective we can use HTTP modules for
ASP.NET employs some HTTP Modules for Output caching, these can be located in the machine.config file.
HTTP Handlers are the code which gets executed when an HTTP request reaches the server.
There will be separate handlers based on the request extensions like .aspx, .asmx, .pdf etc.
A scenario for creating custom handler would be like downloading a research pdf file.
The user will be given a url for the scrip name eg: http://domain/infy2009-20010.pdf. We have to create a custom HTTP handler for handling the .pdf extension. The advantage is that based on the scrip name (infy) we can dynamically create the pdf file based on the years (2009-2010) by parsing the request url.
Othewise, we have to create and store huge number of pdf files for each scrip and for different years. Using HTTP Handlers we can save lot of storage and increase flexibility.
We can create HTTP Handlers by creating a class implementing the IHttpHandler interface and configuring it with IIS.