locked
HttpModule + Global.asax RRS feed

  • Question

  • User-1069184416 posted

    Dear all,

    I had a discussion today with my boss about Global.asax vs. HttpModule. I was trynig to convince him of the HttpModule better than using Global.asax.

    I would like to know what is the major difference between Global.asax vs. HttpModule

    I usually delete the Global.asax file when a new application is created [:$]

    Second question, if we are not using any kind of built-in authentication in asp.net, is it possible to access the Session at every step in the HttpModule PipeLine ?

    Regards

    Tuesday, May 24, 2005 9:33 AM

All replies

  • User1886752246 posted

    A HttpModule implements IHttpModule and you can have as many as you want.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    Global.asax inherits from HttpApplication and you can only have one per webapp. I think a global.asax can do everything a module can do as well as handling application level events (start, end, disposed etc). <o:p></o:p>

    Personally I use HttpModule's whenever I need something executed on a request pipeline since they are very easy to add, remove and reuse elsewhere. I only use a global.asax for Application_Start and Application_Error, although you could probably use a module for both of those as well.<o:p></o:p>

     <o:p></o:p>

    Authentication is quite separate from session state. If you are using the default built session state module then no.

    Have a look at it in Reflector. It retrieves it during the AcquireRequestState event.
    Tuesday, May 24, 2005 11:31 PM
  • User-2103686584 posted
    Global.asax can do everything that an HttpModule can do, and it's the easiest.  That file is also deployed on the server.  Functionally, there's no difference.  HttpModules are classes that are compiled into the binary, and if you have several things to do, you can separate them in several modules.  If you need to be able to share modules, then HttpModule is the way to go.  If you have several pipeline steps you need to perform, HttpModule is the way to go.  If you want quick and dirty, Global.asax is the way to go.
    Saturday, June 25, 2005 1:06 AM