Wednesday, March 4, 2009

httpapplication vs httpmodule

you must be already knowing about httphandlers - they are the endpoints for your requests. for e.g. we can define a httphandler for all request for pages with an externs .klm or .[yourname] and send back a html response. now any request to a page with this extension will output that html response (you can get inventive or witty with the response, i will leave that with you; you r good at it). httphandlers are fine no issues.

but httpapplication and httpmodules are confusing.. granted, we understand that they are not endpoints to request; they get called on the way - while a request is travelling to its endpoint the httphandler. We can use them to do authorization, session activation actions, clearing of sessions, counting number of people currently in the site etc., but why do we need 2 ways of doing the same thing

httpmodule is different form httpapplication in the following ways
1. httpmodule is a compiled dll, httpapplication is a .asax file (so what, you say!! and so do I) - this is just academic - i dont c any non notional advantages
2. httpmodule can be many for a webapplication - one for auth, one for counting, one for whatever you want to do; httpapp is only one file (hmm, i c that i can remove one out of the way by just changing the web.config or add one more once i develop - greater configuration control)
3. httpmodule can be added to your machine.config and all webapplications can make use of it - httpapplication is webapplication specific (now i c, that adds more value)

that is it.. henceforth it should not be confusing..

No comments: