ASP.NET handles all the HTTP
requests coming from the user and generates the appropriate response for it. ASP.NET framework knows how to process different kind of requests based on extension, for example, It can handle request for .aspx, .ascx and .txt files, etc. When it receives any request, it checks the extension to see if it can handle that request and performs some predefined steps to serve that request.
Now as a developer, we might want to have some of our own functionality plugged in. We might want to handle some new kind of requests or perhaps we want to handle an existing request ourselves to have more control on the generated response, for example, we may want to decide how the request for .jpg or .gif files will be handled. Here, we will need an HTTPHandler
to have our functionality in place.
There are also some scenarios where we are ok with the way ASP.NET is handling the requests but we want to perform some additional tasks on each request, i.e., we want to have our tasks execute along with the predefined steps ASP.NET is taking on each request. If we want to do this, we can have HTTPModule
in place to achieve that.
So from the above discussion, it is clear that HTTPHandlers
are used by ASP.NET to handle the specific requests based on extensions. HTTPModule
, on the other hand, is used if we want to have our own functionality working along with the default ASP.NET functionality. There is one Handler for a specific request but there could be N number of modules for that.
Note: The HTTPHandler
example here is just for demonstration purpose, I am not recommending the use of HTTPHandlers
for something that I am about to do now. HTTPHandlers
should ideally be used to customize the handling of existing MIME types and not for serving search engine friendly URLs or non standard URLs.
You can get detailed information of code Download
here
For More details you can check this link
, i got the idea from this side only
No comments:
Post a Comment