See Also: HttpApplication Members
This class is the base class for ASP.NET applications. An application exists on a directory, and if such directory contains a Global.asax file, the contents of that file are used to create a derived type of HttpApplication. The runtime will create one or more classes derived from HttpApplication to handle incoming requests for a directory (an application). The number of live instances at any given time is typically capped by the number of available threads on the thread pool and the instances are reused across different clients and incoming requests.HttpApplication implements the System.Web.IHttpHandler and System.Web.IHttpAsyncHandler which are used to drive the execution of incoming requests. Handing of a request is initiated by invoking the IHttpHandler.ProcessRequest() method for a synchronous operation or IHttpAsyncHandler.BeginProcessRequest to initiate a processing asynchronously.
The application will load and initialize all of the modules listed in the system.web/httpModules section in the machine.config and web.config files. The modules work by hooking up to different stages of the HTTP processing pipeline described below.
The application execution pipeline is made up of a number of steps to which HTTP Modules can hook up. HTTP Modules are types that implement the System.Web.IHttpModule interface and they hook up to or or more of the stages of the Http Application pipeline synchronously (by adding their handler to one of HttpApplication's events) or asynchronously by using one or more of the AddOn methods of HttpApplication.
Steps are executed in order and the application will only move to the next stage of execution when all of the hooks (synchronous and asynchronous) have been executed for the given stage.
Stage Description BeginRequest The first stage of the pipeline processing. AuthenticateRequest Authentication stage. For example the System.Web.Security.FormsAuthenticationModule hooks up to this stage to implement forms authentication. AuthorizeRequest The autorization stage. For example the System.Web.Security.UrlAuthorizationModule uses this synchronously. ResolveRequestCache Caching is handled at this stage. For example Mono's internal OutputCacheModule hooks up to this event to provide caching functionality (if the page has enabled caching). AcquireRequestState Allows session state providers to be written. Mono provides three session state providers: InProc, StateServer and SQLServer based on the data from the "system.web/sessionState" section on machine.config and web.config. PreRequestHandlerExecute An even to hook up before the actual request is handled by the application handler Application handler. This is where user-defined code is executed. PostRequestHandlerExecute Executed immediately after the application request has been executed. ReleaseRequestState Invoked to release any resources associated with the session state. UpdateRequestCache Should be used to update the cache if any. EndRequest The last step of the request processing. Unlike the previous stages, this stage will always be executed regardless of whether a module called HttpApplication.CompleteRequest() or not. If buffering is enabled (the default) the page will be flushed after the EndRequest stage has been completed.
Two other events are triggered: before writing the HTTP headers (HttpApplication.PreSendRequestHeaders) and one before the content of the HTTP request is sent (HttpApplication.PreSendRequestContent).
Namespace: System.Web
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0