April 21, 2011

HTTP Modules Vs Global.asax File

Differences:
    If you view the functionality provided by the HTTP Modules and the Global.asax file you find both are almost similar, But the advantage of using the HTTP Module over Global.aspx file is that they can be re-used by adding them to the GAC (Global Assembly Cache) and registering in the Machine.config file you can use it across all the application running on that server, while global.asax files are application specific.

   And the advantage of using Global.asax file over HTTP Modules is that it provides some extra events that can not be available during  in the HTTP Module implementation. Those events are :
                            1. Application_start
                            2. Session_Start
                            3. Session_End
                            4. Application_End
Along with this Global.asax also enables you to declare and initialize your global objects in your application. 

Another difference is that you can have one Global.asax file in your application and you have to implement all your required logic on that, But in the case of HTTP Module you can divide your required logic in different modules and can have more than one HTTP Module attached in your application.


No comments:

Post a Comment

Your comments are valuable.