ASP.NET Interview Questions

When to use HTTP Modules versus Global.asax Files

When to use HTTP Modules versus Global.asax Files

One should use a module whenever one must create code that depends on application events, and when the following conditions are true:

  • One want to re-use the module in other applications.

  • You want to avoid putting complex code in the Global.asax file.

  • The module applies to all requests in the pipeline (IIS 7.0 Integrated mode only).

One should add code in the Global.asax file whenever

you must create code that depends on application events and you do not have to reuse it across applications. One can also use the Global.asax file when you have to subscribe to events that are not available to modules, such as Session_Start.

Leave a Reply