
Application File Types | 27
ASP.NET
Applications
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
global.asax Files
global.asax performs a similar function in ASP.NET that global.asa performs in
classic ASP. That is, it is an optional file that may contain code to respond to
Application- or Session-level events. Like global.asa in classic ASP, there can be
only one global.asax file per ASP.NET application. Unlike the global.asa file in
classic ASP, which was parsed, the global.asax application file is compiled at
runtime into a .NET managed assembly ultimately derived from the
HttpApplication class. In addition to handling Application- and Session-level
events, such as Session_OnStart, global.asax also allows you to handle events
raised by HttpModules associated with your application (in fact, the Session state
in ASP.NET is implemented as an HttpModule, so its events are already handled
this way).
The global.asax file can be constructed one of two ways. The file can contain the
event handlers and other code you want associated with your application directly,
or it can reference a code-behind class file that contains the event handlers and
code to associate with the application. Note that the code-behind used, if any,
must inherit from the
HttpApplication class in the System.Web namespace. The
latter is the way that the global.asax files ...