Mono Class Library: System.Web Namespace

System.Web.HttpApplication Class

Base class for all ASP.NET applications.

See Also: HttpApplication Members

[System.ComponentModel.ToolboxItem(false)]
public class HttpApplication : System.ComponentModel.IComponent, IHttpAsyncHandler

Remarks

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.

StageDescription
BeginRequestThe first stage of the pipeline processing.
AuthenticateRequestAuthentication stage. For example the System.Web.Security.FormsAuthenticationModule hooks up to this stage to implement forms authentication.
AuthorizeRequestThe autorization stage. For example the System.Web.Security.UrlAuthorizationModule uses this synchronously.
ResolveRequestCacheCaching 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).
AcquireRequestStateAllows 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.
PreRequestHandlerExecuteAn even to hook up before the actual request is handled by the application handler
Application handler.This is where user-defined code is executed.
PostRequestHandlerExecuteExecuted immediately after the application request has been executed.
ReleaseRequestStateInvoked to release any resources associated with the session state.
UpdateRequestCacheShould be used to update the cache if any.
EndRequestThe 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).

Requirements

Namespace: System.Web
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0