ASP.NET

The Application and HTTP Module

This tutorial covers working with application state and application-wide events within your ASP.NET application. In normal desktop applications, the notion of a global meeting place for various parts of an application is well-understood.

After completing this tutorial, you will be able to

  • Use HttpApplication as a rendezvous point for your application
  • Manage data within the HttpApplication object
  • Manage events within the HttpApplication object
  • Work with HTTP Modules

For example, MFC, a C++ class library supporting low-level Windows development, includes a class named CWinApp that holds state useful throughout the program. This state includes such items as a handle to the current instance of the application, a handle to the main window, and the parameters that were passed in when the application started. The CWinApp class also runs the message loop-something that can be done only within the global scope of a Windows application. A running Windows application contains one and only one instance of the CWinApp class, and it's perennially available from anywhere within the application.

Windows Forms-the .NET library supporting Windows forms-has a similar class named Application. It includes the same sort of state (command line parameters, a top-level window, other state required by the program). The Windows Forms Application class also runs the message loop.

Web development also requires the same sort of "global space" that a desktop application requires. Having a global space within a Web application makes implementing features such as caching data and session state possible. Let's take a look at how ASP.NET implements a global space for Web applications.