Handling Application-Level Events

Files with a .asax extension are not served by Web browsers. However, each Web application is created with a Global.asax file. This file is used to warehouse application and session events. For example, each time a request is made to your Web application, the Application_BeginRequest event is fired. You can use this event as an opportunity to perform some preliminary tasks before the rest of the application code runs.

Listing 15.16 provides a listing for the Global.asax file, demonstrating how the color scheme for the Web site can be placed in the HttpContext object. The HttpContext object, instantiated as Context, is unique to each HTTP request. Here I am placing an instance of ColorInfo into the Context collection. ...

Get Visual Basic® .NET Power Coding 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.