HttpApplication Class
Assembly: System.Web (in system.web.dll)
Instances of the HttpApplication class are created in the ASP.NET infrastructure, not by the user directly. One instance of the HttpApplication class is used to process many requests in its lifetime; however, it can process only one request at a time. Thus, member variables can be used to store per-request data.
An application executes events that are handled by modules or user code that is defined in the Global.asax file in the following sequence:
-
After the PostResolveRequestCache event and before the PostMapRequestHandler event, an event handler (a page corresponding to the request URL) is created.
-
PostMapRequestHandler
-
The event handler is executed.
-
After the PostReleaseRequestState event, response filters, if any, filter the output.
The following two examples demonstrate how to use HttpApplication class and its events. The code example demonstrates how to create a custom HTTP module and connect an event to it. The second demonstrates how to modify the Web.config file.
The following code example demonstrates how to create a custom HTTP module and connect the AcquireRequestState event to the HTTP module. HTTP modules intercept each request to Web application resources, thereby allowing you to filter client requests. Any HTTP module that subscribes to an HttpApplication event must implement the IHttpModule interface.
Before an event within a custom HTTP module can occur, you must modify the configuration settings in the Web.config file to notify ASP.NET about the HTTP module. The following code example shows the appropriate configuration setting within the httpModules section of the Web.config file.
- AspNetHostingPermission for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
- AspNetHostingPermission for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.