Initializing Web Applications Using Global.asax

ASP.old provided a file, global.asa, that provided functionality specific to the ASP application and session. You would typically put initialization code in global.asa, which provided a set of event-handling procedures for this purpose.

ASP.NET provides a similar functionality in the file Global.asax. Four categories of entries can appear in a Global.asax file:

  • Application directives

  • Code declaration blocks

  • Server-side object tags

  • Server-side includes

Each of these four categories of entries is discussed in more detail in the next few sections.

Note that when you make a change to Global.asax, as with all ASP.NET files, the binary representation of the script will be automatically recompiled. This isn't ...

Get C#® Developer's Guide to ASP.NET, XML, and ADO.NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.