HttpApplication HttpApplication HttpApplication HttpApplication Class

定义

定义对 ASP.NET 应用程序内所有应用程序对象公用的方法、属性和事件。Defines the methods, properties, and events that are common to all application objects in an ASP.NET application. 此类是用户在 Global.asax 文件中定义的应用程序的基类。This class is the base class for applications that are defined by the user in the Global.asax file.

public ref class HttpApplication : IDisposable, System::ComponentModel::IComponent, System::Web::IHttpAsyncHandler
public class HttpApplication : IDisposable, System.ComponentModel.IComponent, System.Web.IHttpAsyncHandler
type HttpApplication = class
    interface IComponent
    interface IDisposable
    interface IHttpAsyncHandler
    interface IHttpHandler
Public Class HttpApplication
Implements IComponent, IDisposable, IHttpAsyncHandler
继承
HttpApplicationHttpApplicationHttpApplicationHttpApplication
实现

示例

下面两个示例演示如何使用HttpApplication类及其事件。The following two examples demonstrate how to use the HttpApplication class and its events. 第一个示例演示如何创建自定义 HTTP 模块并将事件连接到该模块。The first example demonstrates how to create a custom HTTP module and connect an event to it. 第二个示例演示如何修改 Web.config 文件。The second example demonstrates how to modify the Web.config file.

下面的示例演示如何创建自定义 http 模块并将该AcquireRequestState事件连接到 HTTP 模块。The following example demonstrates how to create a custom HTTP module and connect the AcquireRequestState event to the HTTP module. HTTP 模块会截获对 Web 应用程序资源的每个请求, 从而允许你筛选客户端请求。HTTP modules intercept each request to Web application resources, thereby allowing you to filter client requests. 订阅HttpApplication事件的任何 HTTP 模块都必须IHttpModule实现接口。Any HTTP module that subscribes to an HttpApplication event must implement the IHttpModule interface.

using System;
using System.Web;

namespace Samples.AspNet.CS
{
    public class CustomHTTPModule : IHttpModule
    {
        public CustomHTTPModule()
        {
            // Class constructor.
        }

        // Classes that inherit IHttpModule 
        // must implement the Init and Dispose methods.
        public void Init(HttpApplication app)
        {

            app.AcquireRequestState += new EventHandler(app_AcquireRequestState);
            app.PostAcquireRequestState += new EventHandler(app_PostAcquireRequestState);
        }

        public void Dispose()
        {
            // Add code to clean up the
            // instance variables of a module.
        }

        // Define a custom AcquireRequestState event handler.
        public void app_AcquireRequestState(object o, EventArgs ea)
        {
            HttpApplication httpApp = (HttpApplication)o;
            HttpContext ctx = HttpContext.Current;
            ctx.Response.Write(" Executing AcquireRequestState ");
        }

        // Define a custom PostAcquireRequestState event handler.
        public void app_PostAcquireRequestState(object o, EventArgs ea)
        {
            HttpApplication httpApp = (HttpApplication)o;
            HttpContext ctx = HttpContext.Current;
            ctx.Response.Write(" Executing PostAcquireRequestState ");
        }

    }
}
Imports System.Web

Namespace Samples.AspNet.VB
    Public Class CustomHTTPModule
        Implements IHttpModule

        Public Sub New()

            ' Class constructor.

        End Sub


        ' Classes that inherit IHttpModule 
        ' must implement the Init and Dispose methods.
        Public Sub Init(ByVal app As HttpApplication) Implements IHttpModule.Init

            AddHandler app.AcquireRequestState, AddressOf app_AcquireRequestState
            AddHandler app.PostAcquireRequestState, AddressOf app_PostAcquireRequestState

        End Sub


        Public Sub Dispose() Implements IHttpModule.Dispose

            ' Add code to clean up the
            ' instance variables of a module.

        End Sub


        ' Define a custom AcquireRequestState event handler.
        Public Sub app_AcquireRequestState(ByVal o As Object, ByVal ea As EventArgs)

            Dim httpApp As HttpApplication = CType(o, HttpApplication)
            Dim ctx As HttpContext = HttpContext.Current
            ctx.Response.Write(" Executing AcquireRequestState ")

        End Sub

        ' Define a custom PostAcquireRequestState event handler.
        Public Sub app_PostAcquireRequestState(ByVal o As Object, ByVal ea As EventArgs)

            Dim httpApp As HttpApplication = CType(o, HttpApplication)
            Dim ctx As HttpContext = HttpContext.Current
            ctx.Response.Write(" Executing PostAcquireRequestState ")

        End Sub

    End Class

End Namespace

在自定义 HTTP 模块中发生事件之前, 必须修改 Web.config 文件中的配置设置, 通知 ASP.NET 有关 HTTP 模块的信息。Before an event in 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. 下面的示例演示了 web.config 文件的httpModules节中的适当配置设置。The following example shows the appropriate configuration setting in the httpModules section of the Web.config file. 以下设置适用于 IIS 7.0 经典模式和 IIS 的早期版本。The following setting applies to IIS 7.0 Classic mode and to earlier versions of IIS.

<configuration>  
  <system.web>  
    <httpModules>  
      <add type="Samples.AspNet.CS.CustomHTTPModule"  
        name="CustomHttpModule" />  
      </httpModules>  
  </system.web>  
</configuration>  
<configuration>  
  <system.web>  
    <httpModules>  
      <add type="Samples.AspNet.VB.CustomHTTPModule"  
        name="CustomHttpModule" />  
      </httpModules>  
  </system.web>  
</configuration>  

以下设置适用于 IIS 7.0 集成模式。The following setting applies to IIS 7.0 Integrated mode.

<configuration>  
  <system.webServer>  
    <modules>  
      <add type="Samples.AspNet.CS.CustomHTTPModule"  
        name="CustomHttpModule" />  
      </modules>  
  </system.webServer>  
</configuration>  
<configuration>  
  <system.webServer>  
    <modules>  
      <add type="Samples.AspNet.VB.CustomHTTPModule"  
        name="CustomHttpModule" />  
      <modules>  
  </system.webServer>  
</configuration>  

注解

HttpApplication类的实例在 ASP.NET 基础结构中创建, 而不是由用户直接创建。Instances of the HttpApplication class are created in the ASP.NET infrastructure, not by the user directly. HttpApplication类的一个实例用于处理其生存期内的许多请求。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.

应用程序引发可以由实现IHttpModule接口的自定义模块或 global.asax 文件中定义的事件处理程序代码来处理的事件。An application raises events that can be handled by custom modules that implement the IHttpModule interface or by event handler code that is defined in the Global.asax file. 实现IHttpModule接口的自定义模块可以放在 App_Code 文件夹中, 也可以放在 Bin 文件夹中的 DLL 中。Custom modules that implement the IHttpModule interface can be put in the App_Code folder or in a DLL in the Bin folder.

HttpApplication.NET Framework 版本3.5 中引入。HttpApplication is introduced in the .NET Framework version 3.5. 有关详细信息,请参见版本和依赖关系For more information, see Versions and Dependencies.

备注

在集成模式下运行 IIS 7.0 时, App_Code 文件夹或 Bin 文件夹中的自定义模块适用于请求管道中的所有请求。When running IIS 7.0 in Integrated mode, custom modules in the App_Code folder or Bin folder apply to all requests in the request pipeline. Global.asax 文件中的事件处理程序代码仅适用于映射到 ASP.NET 处理程序的请求。Event handler code in the Global.asax file only applies to requests that are mapped to an ASP.NET handler.

按照以下顺序引发应用程序事件:The application events are raised in the following order:

  1. BeginRequest

  2. AuthenticateRequest

  3. PostAuthenticateRequest

  4. AuthorizeRequest

  5. PostAuthorizeRequest

  6. ResolveRequestCache

  7. PostResolveRequestCache

    在事件之后、事件发生PostMapRequestHandler之前, 将创建一个事件处理程序 (与请求 URL 对应的页)。 PostResolveRequestCacheAfter the PostResolveRequestCache event and before the PostMapRequestHandler event, an event handler (which is a page that corresponds to the request URL) is created. 如果服务器在集成模式下运行 IIS 7.0, 并且至少 .NET Framework 版本 3.0, 则MapRequestHandler会引发事件。When a server is running IIS 7.0 in Integrated mode and at least the .NET Framework version 3.0, the MapRequestHandler event is raised. 如果服务器在经典模式下运行 IIS 7.0 或 IIS 的早期版本, 则无法处理此事件。When a server is running IIS 7.0 in Classic mode or an earlier version of IIS, this event cannot be handled.

  8. PostMapRequestHandler

  9. AcquireRequestState

  10. PostAcquireRequestState

  11. PreRequestHandlerExecute

    执行事件处理程序。The event handler is executed.

  12. PostRequestHandlerExecute

  13. ReleaseRequestState

  14. PostReleaseRequestState

    PostReleaseRequestState引发事件后, 任何现有响应筛选器都将筛选输出。After the PostReleaseRequestState event is raised, any existing response filters will filter the output.

  15. UpdateRequestCache

  16. PostUpdateRequestCache

  17. LogRequestLogRequest.

    此事件在 IIS 7.0 集成模式下受支持, 并且至少 .NET Framework 3。0This event is supported in IIS 7.0 Integrated mode and at least the .NET Framework 3.0

  18. PostLogRequest

    此事件支持 IIS 7.0 集成模式, 并且至少支持 .NET Framework 3。0This event is supported IIS 7.0 Integrated mode and at least the .NET Framework 3.0

  19. EndRequest

构造函数

HttpApplication() HttpApplication() HttpApplication() HttpApplication()

初始化 HttpApplication 类的新实例。Initializes a new instance of the HttpApplication class.

属性

Application Application Application Application

获取应用程序的当前状态。Gets the current state of an application.

Context Context Context Context

获取关于当前请求的 HTTP 特定信息。Gets HTTP-specific information about the current request.

Events Events Events Events

获取处理所有应用程序事件的事件处理程序委托列表。Gets the list of event handler delegates that process all application events.

Modules Modules Modules Modules

获取当前应用程序的模块集合。Gets the collection of modules for the current application.

Request Request Request Request

获取当前请求所对应的内部请求对象。Gets the intrinsic request object for the current request.

Response Response Response Response

获取当前请求所对应的内部响应对象。Gets the intrinsic response object for the current request.

Server Server Server Server

获取当前请求所对应的内部服务器对象。Gets the intrinsic server object for the current request.

Session Session Session Session

获取提供对会话数据的访问的内部会话对象。Gets the intrinsic session object that provides access to session data.

Site Site Site Site

获取或设置 IComponent 实现的网站接口。Gets or sets a site interface for an IComponent implementation.

User User User User

获取当前请求的内部用户对象。Gets the intrinsic user object for the current request.

方法

AddOnAcquireRequestStateAsync(BeginEventHandler, EndEventHandler) AddOnAcquireRequestStateAsync(BeginEventHandler, EndEventHandler) AddOnAcquireRequestStateAsync(BeginEventHandler, EndEventHandler) AddOnAcquireRequestStateAsync(BeginEventHandler, EndEventHandler)

将指定的 AcquireRequestState 事件添加到当前请求的异步 AcquireRequestState 事件处理程序的集合。Adds the specified AcquireRequestState event to the collection of asynchronous AcquireRequestState event handlers for the current request.

AddOnAcquireRequestStateAsync(BeginEventHandler, EndEventHandler, Object) AddOnAcquireRequestStateAsync(BeginEventHandler, EndEventHandler, Object) AddOnAcquireRequestStateAsync(BeginEventHandler, EndEventHandler, Object) AddOnAcquireRequestStateAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 AcquireRequestState 事件添加到当前请求的异步 AcquireRequestState 事件处理程序的集合。Adds the specified AcquireRequestState event to the collection of asynchronous AcquireRequestState event handlers for the current request.

AddOnAuthenticateRequestAsync(BeginEventHandler, EndEventHandler) AddOnAuthenticateRequestAsync(BeginEventHandler, EndEventHandler) AddOnAuthenticateRequestAsync(BeginEventHandler, EndEventHandler) AddOnAuthenticateRequestAsync(BeginEventHandler, EndEventHandler)

将指定的 AuthenticateRequest 事件添加到当前请求的异步 AuthenticateRequest 事件处理程序的集合。Adds the specified AuthenticateRequest event to the collection of asynchronous AuthenticateRequest event handlers for the current request.

AddOnAuthenticateRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnAuthenticateRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnAuthenticateRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnAuthenticateRequestAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 AuthenticateRequest 事件添加到当前请求的异步 AuthenticateRequest 事件处理程序的集合。Adds the specified AuthenticateRequest event to the collection of asynchronous AuthenticateRequest event handlers for the current request.

AddOnAuthorizeRequestAsync(BeginEventHandler, EndEventHandler) AddOnAuthorizeRequestAsync(BeginEventHandler, EndEventHandler) AddOnAuthorizeRequestAsync(BeginEventHandler, EndEventHandler) AddOnAuthorizeRequestAsync(BeginEventHandler, EndEventHandler)

将指定的 AuthorizeRequest 事件添加到当前请求的异步 AuthorizeRequest 事件处理程序的集合。Adds the specified AuthorizeRequest event to the collection of asynchronous AuthorizeRequest event handlers for the current request.

AddOnAuthorizeRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnAuthorizeRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnAuthorizeRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnAuthorizeRequestAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 AuthorizeRequest 事件添加到当前请求的异步 AuthorizeRequest 事件处理程序的集合。Adds the specified AuthorizeRequest event to the collection of asynchronous AuthorizeRequest event handlers for the current request.

AddOnBeginRequestAsync(BeginEventHandler, EndEventHandler) AddOnBeginRequestAsync(BeginEventHandler, EndEventHandler) AddOnBeginRequestAsync(BeginEventHandler, EndEventHandler) AddOnBeginRequestAsync(BeginEventHandler, EndEventHandler)

将指定的 BeginRequest 事件添加到当前请求的异步 BeginRequest 事件处理程序的集合。Adds the specified BeginRequest event to the collection of asynchronous BeginRequest event handlers for the current request.

AddOnBeginRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnBeginRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnBeginRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnBeginRequestAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 BeginRequest 事件添加到当前请求的异步 BeginRequest 事件处理程序的集合。Adds the specified BeginRequest event to the collection of asynchronous BeginRequest event handlers for the current request.

AddOnEndRequestAsync(BeginEventHandler, EndEventHandler) AddOnEndRequestAsync(BeginEventHandler, EndEventHandler) AddOnEndRequestAsync(BeginEventHandler, EndEventHandler) AddOnEndRequestAsync(BeginEventHandler, EndEventHandler)

将指定的 EndRequest 事件添加到当前请求的异步 EndRequest 事件处理程序的集合。Adds the specified EndRequest event to the collection of asynchronous EndRequest event handlers for the current request.

AddOnEndRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnEndRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnEndRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnEndRequestAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 EndRequest 事件添加到当前请求的异步 EndRequest 事件处理程序的集合。Adds the specified EndRequest event to the collection of asynchronous EndRequest event handlers for the current request.

AddOnLogRequestAsync(BeginEventHandler, EndEventHandler) AddOnLogRequestAsync(BeginEventHandler, EndEventHandler) AddOnLogRequestAsync(BeginEventHandler, EndEventHandler) AddOnLogRequestAsync(BeginEventHandler, EndEventHandler)

将指定的 LogRequest 事件添加到当前请求的异步 LogRequest 事件处理程序的集合。Adds the specified LogRequest event to the collection of asynchronous LogRequest event handlers for the current request.

AddOnLogRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnLogRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnLogRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnLogRequestAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 LogRequest 事件添加到当前请求的异步 LogRequest 事件处理程序的集合。Adds the specified LogRequest event to the collection of asynchronous LogRequest event handlers for the current request.

AddOnMapRequestHandlerAsync(BeginEventHandler, EndEventHandler) AddOnMapRequestHandlerAsync(BeginEventHandler, EndEventHandler) AddOnMapRequestHandlerAsync(BeginEventHandler, EndEventHandler) AddOnMapRequestHandlerAsync(BeginEventHandler, EndEventHandler)

将指定的 MapRequestHandler 事件添加到当前请求的异步 MapRequestHandler 事件处理程序的集合。Adds the specified MapRequestHandler event to the collection of asynchronous MapRequestHandler event handlers for the current request.

AddOnMapRequestHandlerAsync(BeginEventHandler, EndEventHandler, Object) AddOnMapRequestHandlerAsync(BeginEventHandler, EndEventHandler, Object) AddOnMapRequestHandlerAsync(BeginEventHandler, EndEventHandler, Object) AddOnMapRequestHandlerAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 MapRequestHandler 事件添加到当前请求的异步 MapRequestHandler 事件处理程序的集合。Adds the specified MapRequestHandler event to the collection of asynchronous MapRequestHandler event handlers for the current request.

AddOnPostAcquireRequestStateAsync(BeginEventHandler, EndEventHandler) AddOnPostAcquireRequestStateAsync(BeginEventHandler, EndEventHandler) AddOnPostAcquireRequestStateAsync(BeginEventHandler, EndEventHandler) AddOnPostAcquireRequestStateAsync(BeginEventHandler, EndEventHandler)

将指定的 PostAcquireRequestState 事件添加到当前请求的异步 PostAcquireRequestState 事件处理程序的集合。Adds the specified PostAcquireRequestState event to the collection of asynchronous PostAcquireRequestState event handlers for the current request.

AddOnPostAcquireRequestStateAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostAcquireRequestStateAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostAcquireRequestStateAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostAcquireRequestStateAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 PostAcquireRequestState 事件添加到当前请求的异步 PostAcquireRequestState 事件处理程序的集合。Adds the specified PostAcquireRequestState event to the collection of asynchronous PostAcquireRequestState event handlers for the current request.

AddOnPostAuthenticateRequestAsync(BeginEventHandler, EndEventHandler) AddOnPostAuthenticateRequestAsync(BeginEventHandler, EndEventHandler) AddOnPostAuthenticateRequestAsync(BeginEventHandler, EndEventHandler) AddOnPostAuthenticateRequestAsync(BeginEventHandler, EndEventHandler)

将指定的 PostAuthenticateRequest 事件添加到当前请求的异步 PostAuthenticateRequest 事件处理程序的集合。Adds the specified PostAuthenticateRequest event to the collection of asynchronous PostAuthenticateRequest event handlers for the current request.

AddOnPostAuthenticateRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostAuthenticateRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostAuthenticateRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostAuthenticateRequestAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 PostAuthorizeRequest 事件添加到当前请求的异步 PostAuthorizeRequest 事件处理程序的集合。Adds the specified PostAuthorizeRequest event to the collection of asynchronous PostAuthorizeRequest event handlers for the current request.

AddOnPostAuthorizeRequestAsync(BeginEventHandler, EndEventHandler) AddOnPostAuthorizeRequestAsync(BeginEventHandler, EndEventHandler) AddOnPostAuthorizeRequestAsync(BeginEventHandler, EndEventHandler) AddOnPostAuthorizeRequestAsync(BeginEventHandler, EndEventHandler)

将指定的 PostAuthorizeRequest 事件添加到当前请求的异步 PostAuthorizeRequest 事件处理程序的集合。Adds the specified PostAuthorizeRequest event to the collection of asynchronous PostAuthorizeRequest event handlers for the current request.

AddOnPostAuthorizeRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostAuthorizeRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostAuthorizeRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostAuthorizeRequestAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 PostAuthorizeRequest 添加到当前请求的异步 PostAuthorizeRequest 事件处理程序的集合中。Adds the specified PostAuthorizeRequest to the collection of asynchronous PostAuthorizeRequest event handlers for the current request.

AddOnPostLogRequestAsync(BeginEventHandler, EndEventHandler) AddOnPostLogRequestAsync(BeginEventHandler, EndEventHandler) AddOnPostLogRequestAsync(BeginEventHandler, EndEventHandler) AddOnPostLogRequestAsync(BeginEventHandler, EndEventHandler)

将指定的 PostLogRequest 事件添加到当前请求的异步 PostLogRequest 事件处理程序的集合。Adds the specified PostLogRequest event to the collection of asynchronous PostLogRequest event handlers for the current request.

AddOnPostLogRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostLogRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostLogRequestAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostLogRequestAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 PostLogRequest 事件添加到当前请求的异步 PostLogRequest 事件处理程序的集合。Adds the specified PostLogRequest event to the collection of asynchronous PostLogRequest event handlers for the current request.

AddOnPostMapRequestHandlerAsync(BeginEventHandler, EndEventHandler) AddOnPostMapRequestHandlerAsync(BeginEventHandler, EndEventHandler) AddOnPostMapRequestHandlerAsync(BeginEventHandler, EndEventHandler) AddOnPostMapRequestHandlerAsync(BeginEventHandler, EndEventHandler)

将指定的 PostMapRequestHandler 事件添加到当前请求的异步 PostMapRequestHandler 事件处理程序的集合。Adds the specified PostMapRequestHandler event to the collection of asynchronous PostMapRequestHandler event handlers for the current request.

AddOnPostMapRequestHandlerAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostMapRequestHandlerAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostMapRequestHandlerAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostMapRequestHandlerAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 PostMapRequestHandler 事件添加到当前请求的异步 PostMapRequestHandler 事件处理程序的集合。Adds the specified PostMapRequestHandler event to the collection of asynchronous PostMapRequestHandler event handlers for the current request.

AddOnPostReleaseRequestStateAsync(BeginEventHandler, EndEventHandler) AddOnPostReleaseRequestStateAsync(BeginEventHandler, EndEventHandler) AddOnPostReleaseRequestStateAsync(BeginEventHandler, EndEventHandler) AddOnPostReleaseRequestStateAsync(BeginEventHandler, EndEventHandler)

将指定的 PostReleaseRequestState 事件添加到当前请求的异步 PostReleaseRequestState 事件处理程序的集合。Adds the specified PostReleaseRequestState event to the collection of asynchronous PostReleaseRequestState event handlers for the current request.

AddOnPostReleaseRequestStateAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostReleaseRequestStateAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostReleaseRequestStateAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostReleaseRequestStateAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 PostReleaseRequestState 事件添加到当前请求的异步 PostReleaseRequestState 事件处理程序的集合。Adds the specified PostReleaseRequestState event to the collection of asynchronous PostReleaseRequestState event handlers for the current request.

AddOnPostRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler) AddOnPostRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler) AddOnPostRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler) AddOnPostRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler)

将指定的 PostRequestHandlerExecute 事件添加到当前请求的异步 PostRequestHandlerExecute 事件处理程序的集合。Adds the specified PostRequestHandlerExecute event to the collection of asynchronous PostRequestHandlerExecute event handlers for the current request.

AddOnPostRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 PostRequestHandlerExecute 事件添加到当前请求的异步 PostRequestHandlerExecute 事件处理程序的集合。Adds the specified PostRequestHandlerExecute event to the collection of asynchronous PostRequestHandlerExecute event handlers for the current request.

AddOnPostResolveRequestCacheAsync(BeginEventHandler, EndEventHandler) AddOnPostResolveRequestCacheAsync(BeginEventHandler, EndEventHandler) AddOnPostResolveRequestCacheAsync(BeginEventHandler, EndEventHandler) AddOnPostResolveRequestCacheAsync(BeginEventHandler, EndEventHandler)

将指定的 PostResolveRequestCache 事件添加到当前请求的异步 PostResolveRequestCache 事件处理程序的集合。Adds the specified PostResolveRequestCache event to the collection of asynchronous PostResolveRequestCache event handlers for the current request.

AddOnPostResolveRequestCacheAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostResolveRequestCacheAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostResolveRequestCacheAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostResolveRequestCacheAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 PostResolveRequestCache 事件添加到当前请求的异步 PostResolveRequestCache 事件处理程序的集合。Adds the specified PostResolveRequestCache event to the collection of asynchronous PostResolveRequestCache event handlers for the current request.

AddOnPostUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler) AddOnPostUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler) AddOnPostUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler) AddOnPostUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler)

将指定的 PostUpdateRequestCache 事件添加到当前请求的异步 PostUpdateRequestCache 事件处理程序的集合。Adds the specified PostUpdateRequestCache event to the collection of asynchronous PostUpdateRequestCache event handlers for the current request.

AddOnPostUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler, Object) AddOnPostUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 PostUpdateRequestCache 事件添加到当前请求的异步 PostUpdateRequestCache 事件处理程序的集合。Adds the specified PostUpdateRequestCache event to the collection of asynchronous PostUpdateRequestCache event handlers for the current request.

AddOnPreRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler) AddOnPreRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler) AddOnPreRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler) AddOnPreRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler)

将指定的 PreRequestHandlerExecute 事件添加到当前请求的异步 PreRequestHandlerExecute 事件处理程序的集合。Adds the specified PreRequestHandlerExecute event to the collection of asynchronous PreRequestHandlerExecute event handlers for the current request.

AddOnPreRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler, Object) AddOnPreRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler, Object) AddOnPreRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler, Object) AddOnPreRequestHandlerExecuteAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 PreRequestHandlerExecute 事件添加到当前请求的异步 PreRequestHandlerExecute 事件处理程序的集合。Adds the specified PreRequestHandlerExecute event to the collection of asynchronous PreRequestHandlerExecute event handlers for the current request.

AddOnReleaseRequestStateAsync(BeginEventHandler, EndEventHandler) AddOnReleaseRequestStateAsync(BeginEventHandler, EndEventHandler) AddOnReleaseRequestStateAsync(BeginEventHandler, EndEventHandler) AddOnReleaseRequestStateAsync(BeginEventHandler, EndEventHandler)

将指定的 ReleaseRequestState 事件添加到当前请求的异步 ReleaseRequestState 事件处理程序的集合。Adds the specified ReleaseRequestState event to the collection of asynchronous ReleaseRequestState event handlers for the current request.

AddOnReleaseRequestStateAsync(BeginEventHandler, EndEventHandler, Object) AddOnReleaseRequestStateAsync(BeginEventHandler, EndEventHandler, Object) AddOnReleaseRequestStateAsync(BeginEventHandler, EndEventHandler, Object) AddOnReleaseRequestStateAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 ReleaseRequestState 事件添加到当前请求的异步 ReleaseRequestState 事件处理程序的集合。Adds the specified ReleaseRequestState event to the collection of asynchronous ReleaseRequestState event handlers for the current request.

AddOnResolveRequestCacheAsync(BeginEventHandler, EndEventHandler) AddOnResolveRequestCacheAsync(BeginEventHandler, EndEventHandler) AddOnResolveRequestCacheAsync(BeginEventHandler, EndEventHandler) AddOnResolveRequestCacheAsync(BeginEventHandler, EndEventHandler)

将指定的 ResolveRequestCache 事件处理程序添加到当前请求的异步 ResolveRequestCache 事件处理程序的集合。Adds the specified ResolveRequestCache event handler to the collection of asynchronous ResolveRequestCache event handlers for the current request.

AddOnResolveRequestCacheAsync(BeginEventHandler, EndEventHandler, Object) AddOnResolveRequestCacheAsync(BeginEventHandler, EndEventHandler, Object) AddOnResolveRequestCacheAsync(BeginEventHandler, EndEventHandler, Object) AddOnResolveRequestCacheAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 ResolveRequestCache 事件处理程序添加到当前请求的异步 ResolveRequestCache 事件处理程序的集合。Adds the specified ResolveRequestCache event handler to the collection of asynchronous ResolveRequestCache event handlers for the current request.

AddOnUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler) AddOnUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler) AddOnUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler) AddOnUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler)

将指定的 UpdateRequestCache 事件添加到当前请求的异步 UpdateRequestCache 事件处理程序的集合。Adds the specified UpdateRequestCache event to the collection of asynchronous UpdateRequestCache event handlers for the current request.

AddOnUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler, Object) AddOnUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler, Object) AddOnUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler, Object) AddOnUpdateRequestCacheAsync(BeginEventHandler, EndEventHandler, Object)

将指定的 UpdateRequestCache 事件添加到当前请求的异步 UpdateRequestCache 事件处理程序的集合。Adds the specified UpdateRequestCache event to the collection of asynchronous UpdateRequestCache event handlers for the current request.

CompleteRequest() CompleteRequest() CompleteRequest() CompleteRequest()

使 ASP.NET 跳过 HTTP 执行管线链中的所有事件和筛选并直接执行 EndRequest 事件。Causes ASP.NET to bypass all events and filtering in the HTTP pipeline chain of execution and directly execute the EndRequest event.

Dispose() Dispose() Dispose() Dispose()

处置 HttpApplication 实例。Disposes the HttpApplication instance.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetOutputCacheProviderName(HttpContext) GetOutputCacheProviderName(HttpContext) GetOutputCacheProviderName(HttpContext) GetOutputCacheProviderName(HttpContext)

获取为网站配置的默认输出缓存提供程序的名称。Gets the name of the default output-cache provider that is configured for a Web site.

GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
GetVaryByCustomString(HttpContext, String) GetVaryByCustomString(HttpContext, String) GetVaryByCustomString(HttpContext, String) GetVaryByCustomString(HttpContext, String)

提供 VaryByCustom 属性在整个应用程序范围内的实现。Provides an application-wide implementation of the VaryByCustom property.

Init() Init() Init() Init()

在添加所有事件处理程序模块之后执行自定义初始化代码。Executes custom initialization code after all event handler modules have been added.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
OnExecuteRequestStep(Action<HttpContextBase,Action>) OnExecuteRequestStep(Action<HttpContextBase,Action>) OnExecuteRequestStep(Action<HttpContextBase,Action>) OnExecuteRequestStep(Action<HttpContextBase,Action>)

指定在执行请求执行步骤时调用的回调。Specifies a callback to invoke when a request execution step is executed.

RegisterModule(Type) RegisterModule(Type) RegisterModule(Type) RegisterModule(Type)

注册应用程序模块。Registers an application module.

ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

事件

AcquireRequestState AcquireRequestState AcquireRequestState AcquireRequestState

当 ASP.NET 获取与当前请求关联的当前状态(如会话状态)时发生。Occurs when ASP.NET acquires the current state (for example, session state) that is associated with the current request.

AuthenticateRequest AuthenticateRequest AuthenticateRequest AuthenticateRequest

当安全模块已建立用户标识时发生。Occurs when a security module has established the identity of the user.

AuthorizeRequest AuthorizeRequest AuthorizeRequest AuthorizeRequest

当安全模块已验证用户授权时发生。Occurs when a security module has verified user authorization.

BeginRequest BeginRequest BeginRequest BeginRequest

在 ASP.NET 响应请求时作为 HTTP 执行管线链中的第一个事件发生。Occurs as the first event in the HTTP pipeline chain of execution when ASP.NET responds to a request.

Disposed Disposed Disposed Disposed

在释放应用程序时发生。Occurs when the application is disposed.

EndRequest EndRequest EndRequest EndRequest

在 ASP.NET 响应请求时作为 HTTP 执行管线链中的最后一个事件发生。Occurs as the last event in the HTTP pipeline chain of execution when ASP.NET responds to a request.

Error Error Error Error

当引发未经处理的异常时发生。Occurs when an unhandled exception is thrown.

LogRequest LogRequest LogRequest LogRequest

恰好在 ASP.NET 为当前请求执行任何记录之前发生。Occurs just before ASP.NET performs any logging for the current request.

MapRequestHandler MapRequestHandler MapRequestHandler MapRequestHandler

在选择了用来响应请求的处理程序时发生。Occurs when the handler is selected to respond to the request.

PostAcquireRequestState PostAcquireRequestState PostAcquireRequestState PostAcquireRequestState

在已获得与当前请求关联的请求状态(例如会话状态)时发生。Occurs when the request state (for example, session state) that is associated with the current request has been obtained.

PostAuthenticateRequest PostAuthenticateRequest PostAuthenticateRequest PostAuthenticateRequest

当安全模块已建立用户标识时发生。Occurs when a security module has established the identity of the user.

PostAuthorizeRequest PostAuthorizeRequest PostAuthorizeRequest PostAuthorizeRequest

在当前请求的用户已获授权时发生。Occurs when the user for the current request has been authorized.

PostLogRequest PostLogRequest PostLogRequest PostLogRequest

在 ASP.NET 处理完 LogRequest 事件的所有事件处理程序后发生。Occurs when ASP.NET has completed processing all the event handlers for the LogRequest event.

PostMapRequestHandler PostMapRequestHandler PostMapRequestHandler PostMapRequestHandler

在 ASP.NET 已将当前请求映射到相应的事件处理程序时发生。Occurs when ASP.NET has mapped the current request to the appropriate event handler.

PostReleaseRequestState PostReleaseRequestState PostReleaseRequestState PostReleaseRequestState

在 ASP.NET 已完成所有请求事件处理程序的执行并且请求状态数据已存储时发生。Occurs when ASP.NET has completed executing all request event handlers and the request state data has been stored.

PostRequestHandlerExecute PostRequestHandlerExecute PostRequestHandlerExecute PostRequestHandlerExecute

在 ASP.NET 事件处理程序(例如,某页或某个 XML Web service)执行完毕时发生。Occurs when the ASP.NET event handler (for example, a page or an XML Web service) finishes execution.

PostResolveRequestCache PostResolveRequestCache PostResolveRequestCache PostResolveRequestCache

在 ASP.NET 跳过当前事件处理程序的执行并允许缓存模块满足来自缓存的请求时发生。Occurs when ASP.NET bypasses execution of the current event handler and allows a caching module to serve a request from the cache.

PostUpdateRequestCache PostUpdateRequestCache PostUpdateRequestCache PostUpdateRequestCache

在 ASP.NET 完成缓存模块的更新并存储了用于从缓存中为后续请求提供服务的响应后,发生此事件。Occurs when ASP.NET finishes updating caching modules and storing responses that are used to serve subsequent requests from the cache.

PreRequestHandlerExecute PreRequestHandlerExecute PreRequestHandlerExecute PreRequestHandlerExecute

恰好在 ASP.NET 开始执行事件处理程序(例如,某页或某个 XML Web services)前发生。Occurs just before ASP.NET starts executing an event handler (for example, a page or an XML Web service).

PreSendRequestContent PreSendRequestContent PreSendRequestContent PreSendRequestContent

恰好在 ASP.NET 向客户端发送内容之前发生。Occurs just before ASP.NET sends content to the client.

PreSendRequestHeaders PreSendRequestHeaders PreSendRequestHeaders PreSendRequestHeaders

恰好在 ASP.NET 向客户端发送 HTTP 标头之前发生。Occurs just before ASP.NET sends HTTP headers to the client.

ReleaseRequestState ReleaseRequestState ReleaseRequestState ReleaseRequestState

在 ASP.NET 执行完所有请求事件处理程序后发生。Occurs after ASP.NET finishes executing all request event handlers. 该事件将使状态模块保存当前状态数据。This event causes state modules to save the current state data.

RequestCompleted RequestCompleted RequestCompleted RequestCompleted

当托管对象与已经释放的请求相关联时发生。Occurs when the managed objects that are associated with the request have been released.

ResolveRequestCache ResolveRequestCache ResolveRequestCache ResolveRequestCache

在 ASP.NET 完成授权事件以使缓存模块从缓存中为请求提供服务后发生,从而绕过事件处理程序(例如某个页或 XML Web services)的执行。Occurs when ASP.NET finishes an authorization event to let the caching modules serve requests from the cache, bypassing execution of the event handler (for example, a page or an XML Web service).

UpdateRequestCache UpdateRequestCache UpdateRequestCache UpdateRequestCache

当 ASP.NET 执行完事件处理程序以使缓存模块存储将用于从缓存为后续请求提供服务的响应时发生。Occurs when ASP.NET finishes executing an event handler in order to let caching modules store responses that will be used to serve subsequent requests from the cache.

显式界面实现

IHttpAsyncHandler.BeginProcessRequest(HttpContext, AsyncCallback, Object) IHttpAsyncHandler.BeginProcessRequest(HttpContext, AsyncCallback, Object) IHttpAsyncHandler.BeginProcessRequest(HttpContext, AsyncCallback, Object) IHttpAsyncHandler.BeginProcessRequest(HttpContext, AsyncCallback, Object)

启动对 HTTP 事件处理程序的异步调用。Initiates an asynchronous call to the HTTP event handler.

IHttpAsyncHandler.EndProcessRequest(IAsyncResult) IHttpAsyncHandler.EndProcessRequest(IAsyncResult) IHttpAsyncHandler.EndProcessRequest(IAsyncResult) IHttpAsyncHandler.EndProcessRequest(IAsyncResult)

在进程完成时提供一个异步进程 End 方法。Provides an asynchronous process End method when the process finishes.

IHttpHandler.IsReusable IHttpHandler.IsReusable IHttpHandler.IsReusable IHttpHandler.IsReusable

获取一个 Boolean 值,它指示其他请求是否可以使用 IHttpHandler 对象。Gets a Boolean value indicating whether another request can use the IHttpHandler object.

IHttpHandler.ProcessRequest(HttpContext) IHttpHandler.ProcessRequest(HttpContext) IHttpHandler.ProcessRequest(HttpContext) IHttpHandler.ProcessRequest(HttpContext)

通过实现 IHttpHandler 接口的自定义 HTTP 处理程序启用 HTTP Web 请求的处理。Enables processing of HTTP Web requests by a custom HTTP handler that implements the IHttpHandler interface.

适用于

另请参阅