What is GLOBAL.ASAX file?


The Global.asax, also known as the ASP.NET application file, is located in the root directory of an ASP.NET application. This file contains code that is executed in response to application-level and session-level events raised by ASP.NET or by HTTP modules. You can also define ‘objects’ with application-wide or session-wide scope in the Global.asax file. These events and objects declared in the Global.asax are applied to all resources in that web application.

Note 1: The Global.asax is an optional file. Use it only when there is a need for it.

Note 2: If a user requests the Global.asax file, the request is rejected. External users cannot view the file.

The Global.asax file is parsed and dynamically compiled by ASP.NET. You can deploy this file as an assembly in the \bin directory of an ASP.NET application.

How to create Global.asax

Adding a Global.asax to your web project is quiet simple.

Open Visual Studio 2005 or 2008 > Create a new website > Go to the Solution Explorer > Add New Item > Global Application Class > Add.

No comments:

Post a Comment