Global.asax

Global.asax

Global.asax is an optional file used to declare and handle application- and session-level events and objects. Global.asax is the ASP.NET extension of the ASP Global.asa file. The Global.asax file resides in the IIS virtual root of an ASP.NET application. At run time, upon the arrival of the first request, Global.asax is parsed and compiled into a dynamically generated .NET Framework class. ASP.NET is configured so that any direct request for the Global.asax is automatically rejected, external users cannot view or download the code in it. [ [http://msdn2.microsoft.com/en-us/library/2027ewzw.aspx MSDN: Global.asax Syntax] ]

Code to handle application events (such as the start and end of an application) resides in Global.asax. Such event code cannot reside in the ASP.NET page or web service code itself, since during the start or end of the application, its code has not yet been loaded (or unloaded). Global.asax is also used to declare data that is available across different application requests or across different browser sessions. This process is known as application and session state management.

The Global.asax file must reside in the IIS virtual root. Remember that a virtual root can be thought of as the container of a web application. Events and state specified in the global file are then applied to all resources housed within the web application. If, for example, Global.asax defines a state application variable, all .aspx files within the virtual root will be able to access the variable.

The ASP.NET Global.asax file can coexist with the ASP Global.asa file. You can create a Global.asax file either in a WYSIWYG designer or as a compiled class that you deploy in your application's "Bin" directory as an assembly. However, in the latter case, you still need a Global.asax file that refers to the assembly.

Like an ASP.NET page, the Global.asax file is compiled upon the arrival of the first request for any resource in the application. The similarity continues when changes are made to the Global.asax file: ASP.NET automatically notices the changes, recompiles the file, and directs all new requests to the newest "compilation".

ee also

* ASP.NET
* IIS
* ASP

References


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • Global.asax — es un archivo opcional usado en las aplicación web de ASP.NET para declarar y manejar eventos y objetos a nivel de aplicación y de sesión. Global.asax es la extensión de archivo Global.asa utilizado en ASP. El archivo Global.asax reside en el… …   Wikipedia Español

  • ASP.NET — Not to be confused with UNESCO ASPNet. ASP.NET Developer(s) Microsoft Initial release January 2002 Stable release 4.0.30319.1 (4.0) / 12 April 2010; 18 months ago (2010 04 12) …   Wikipedia

  • ASP.NET — es un framework para aplicaciones web desarrollado y comercializado por Microsoft. Es usado por programadores para construir sitios web dinámicos, aplicaciones web y servicios web XML. Apareció en enero de 2002 con la versión 1.0 del .NET… …   Wikipedia Español

  • Список воздушных судов вооружённых сил Германии — Логотип ВВС Германии Список воздушных судов вооружённых сил Германии [1]. Содержание 1 …   Википедия

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”