HttpApplication 類別

定義

定義 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
繼承
HttpApplication
實作

範例

下列兩個範例示範如何使用 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

    PostResolveRequestCache 事件之後和 PostMapRequestHandler 事件之前,會建立事件處理常式(對應至要求 URL 的頁面)。After 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 中執行 IIS 7.0 時,就無法處理這個事件。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. LogRequest.LogRequest.

    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 類別的新執行個體。Initializes a new instance of the HttpApplication class.

屬性

Application

取得應用程式目前的狀態。Gets the current state of an application.

Context

取得有關目前要求的 HTTP 特有資訊。Gets HTTP-specific information about the current request.

Events

取得處理所有應用程式事件的事件處理常式委派 (Delegate) 的清單。Gets the list of event handler delegates that process all application events.

Modules

取得目前應用程式的模組集合。Gets the collection of modules for the current application.

Request

取得目前要求的內建要求物件。Gets the intrinsic request object for the current request.

Response

取得目前要求的內建回應物件。Gets the intrinsic response object for the current request.

Server

取得目前要求的內建伺服器物件。Gets the intrinsic server object for the current request.

Session

取得提供工作階段資料存取的內建工作階段物件。Gets the intrinsic session object that provides access to session data.

Site

取得或設定 IComponent 實作的位置介面。Gets or sets a site interface for an IComponent implementation.

User

取得目前要求的內建使用者物件。Gets the intrinsic user object for the current request.

方法

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)

將指定的 AcquireRequestState 事件加入目前要求之非同步 AcquireRequestState 事件處理常式的集合。Adds the specified AcquireRequestState event to the collection of asynchronous AcquireRequestState event handlers for the current request.

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)

將指定的 AuthenticateRequest 事件加入目前要求之非同步 AuthenticateRequest 事件處理常式的集合。Adds the specified AuthenticateRequest event to the collection of asynchronous AuthenticateRequest event handlers for the current request.

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)

將指定的 AuthorizeRequest 事件加入目前要求之非同步 AuthorizeRequest 事件處理常式的集合。Adds the specified AuthorizeRequest event to the collection of asynchronous AuthorizeRequest event handlers for the current request.

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)

將指定的 BeginRequest 事件加入目前要求之非同步 BeginRequest 事件處理常式的集合。Adds the specified BeginRequest event to the collection of asynchronous BeginRequest event handlers for the current request.

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)

將指定的 EndRequest 事件加入目前要求之非同步 EndRequest 事件處理常式的集合。Adds the specified EndRequest event to the collection of asynchronous EndRequest event handlers for the current request.

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)

將指定的 LogRequest 事件加入目前要求之非同步 LogRequest 事件處理常式的集合。Adds the specified LogRequest event to the collection of asynchronous LogRequest event handlers for the current request.

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)

將指定的 MapRequestHandler 事件加入目前要求之非同步 MapRequestHandler 事件處理常式的集合。Adds the specified MapRequestHandler event to the collection of asynchronous MapRequestHandler event handlers for the current request.

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)

將指定的 PostAcquireRequestState 事件加入目前要求之非同步 PostAcquireRequestState 事件處理常式的集合。Adds the specified PostAcquireRequestState event to the collection of asynchronous PostAcquireRequestState event handlers for the current request.

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)

將指定的 PostAuthorizeRequest 事件加入目前要求之非同步 PostAuthorizeRequest 事件處理常式的集合。Adds the specified PostAuthorizeRequest event to the collection of asynchronous PostAuthorizeRequest event handlers for the current request.

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)

將指定的 PostAuthorizeRequest 加入目前要求之非同步 PostAuthorizeRequest 事件處理常式的集合。Adds the specified PostAuthorizeRequest to the collection of asynchronous PostAuthorizeRequest event handlers for the current request.

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)

將指定的 PostLogRequest 事件加入目前要求之非同步 PostLogRequest 事件處理常式的集合。Adds the specified PostLogRequest event to the collection of asynchronous PostLogRequest event handlers for the current request.

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)

將指定的 PostMapRequestHandler 事件加入目前要求之非同步 PostMapRequestHandler 事件處理常式的集合。Adds the specified PostMapRequestHandler event to the collection of asynchronous PostMapRequestHandler event handlers for the current request.

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)

將指定的 PostReleaseRequestState 事件加入目前要求之非同步 PostReleaseRequestState 事件處理常式的集合。Adds the specified PostReleaseRequestState event to the collection of asynchronous PostReleaseRequestState event handlers for the current request.

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)

將指定的 PostRequestHandlerExecute 事件加入目前要求之非同步 PostRequestHandlerExecute 事件處理常式的集合。Adds the specified PostRequestHandlerExecute event to the collection of asynchronous PostRequestHandlerExecute event handlers for the current request.

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)

將指定的 PostResolveRequestCache 事件加入目前要求之非同步 PostResolveRequestCache 事件處理常式的集合。Adds the specified PostResolveRequestCache event to the collection of asynchronous PostResolveRequestCache event handlers for the current request.

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)

將指定的 PostUpdateRequestCache 事件加入目前要求之非同步 PostUpdateRequestCache 事件處理常式的集合。Adds the specified PostUpdateRequestCache event to the collection of asynchronous PostUpdateRequestCache event handlers for the current request.

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)

將指定的 PreRequestHandlerExecute 事件加入目前要求之非同步 PreRequestHandlerExecute 事件處理常式的集合。Adds the specified PreRequestHandlerExecute event to the collection of asynchronous PreRequestHandlerExecute event handlers for the current request.

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)

將指定的 ReleaseRequestState 事件加入目前要求之非同步 ReleaseRequestState 事件處理常式的集合。Adds the specified ReleaseRequestState event to the collection of asynchronous ReleaseRequestState event handlers for the current request.

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)

將指定的 ResolveRequestCache 事件處理常式加入目前要求之非同步 ResolveRequestCache 事件處理常式的集合。Adds the specified ResolveRequestCache event handler to the collection of asynchronous ResolveRequestCache event handlers for the current request.

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)

將指定的 UpdateRequestCache 事件加入目前要求之非同步 UpdateRequestCache 事件處理常式的集合。Adds the specified UpdateRequestCache event to the collection of asynchronous UpdateRequestCache event handlers for the current request.

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()

處置 HttpApplication 執行個體。Disposes the HttpApplication instance.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetOutputCacheProviderName(HttpContext)

取得設定用於網站之預設輸出快取提供者的名稱。Gets the name of the default output-cache provider that is configured for a Web site.

GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
GetVaryByCustomString(HttpContext, String)

提供 VaryByCustom 屬性的全應用程式實作。Provides an application-wide implementation of the VaryByCustom property.

Init()

在所有事件處理常式的模組已經加入後,執行自訂初始化程式碼。Executes custom initialization code after all event handler modules have been added.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
OnExecuteRequestStep(Action<HttpContextBase,Action>)

指定已執行要求執行步驟時要叫用的回呼。Specifies a callback to invoke when a request execution step is executed.

RegisterModule(Type)

註冊應用程式模組。Registers an application module.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

事件

AcquireRequestState

當 ASP.NET 取得與目前要求關聯的目前狀態 (例如,工作階段狀態) 時發生。Occurs when ASP.NET acquires the current state (for example, session state) that is associated with the current request.

AuthenticateRequest

發生於安全性模組建立使用者的識別 (Identity) 時。Occurs when a security module has established the identity of the user.

AuthorizeRequest

發生於安全性模式驗證使用者授權時。Occurs when a security module has verified user authorization.

BeginRequest

發生於 ASP.NET 回應要求時,做為 HTTP 管線的執行鏈結裡的第一個事件。Occurs as the first event in the HTTP pipeline chain of execution when ASP.NET responds to a request.

Disposed

發生於處置應用程式時。Occurs when the application is disposed.

EndRequest

發生於 ASP.NET 回應要求時,做為 HTTP 管線的執行鏈結裡的最後一個事件。Occurs as the last event in the HTTP pipeline chain of execution when ASP.NET responds to a request.

Error

當擲回未處理的例外狀況時發生。Occurs when an unhandled exception is thrown.

LogRequest

發生於 ASP.NET 執行目前要求的任何記錄之前。Occurs just before ASP.NET performs any logging for the current request.

MapRequestHandler

發生於選取處理常式以回應要求時。Occurs when the handler is selected to respond to the request.

PostAcquireRequestState

當取得與目前要求關聯的要求狀態 (例如,工作階段狀態) 時發生。Occurs when the request state (for example, session state) that is associated with the current request has been obtained.

PostAuthenticateRequest

發生於安全性模組建立使用者的識別 (Identity) 時。Occurs when a security module has established the identity of the user.

PostAuthorizeRequest

當目前要求的使用者已獲授權時發生。Occurs when the user for the current request has been authorized.

PostLogRequest

發生於 ASP.NET 完成處理 LogRequest 事件的所有事件處理常式時。Occurs when ASP.NET has completed processing all the event handlers for the LogRequest event.

PostMapRequestHandler

當 ASP.NET 已對應目前要求至適當事件處理常式時發生。Occurs when ASP.NET has mapped the current request to the appropriate event handler.

PostReleaseRequestState

當 ASP.NET 已完成執行所有要求事件處理常式並已儲存要求狀態資料時發生。Occurs when ASP.NET has completed executing all request event handlers and the request state data has been stored.

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

當 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

當 ASP.NET 完成更新快取模組並儲存回應 (用來從快取中服務後續的要求) 時發生。Occurs when ASP.NET finishes updating caching modules and storing responses that are used to serve subsequent requests from the cache.

PreRequestHandlerExecute

正好發生於 ASP.NET 開始執行事件處理常式 (例如,網頁或 XML Web Service) 之前。Occurs just before ASP.NET starts executing an event handler (for example, a page or an XML Web service).

PreSendRequestContent

正好發生於 ASP.NET 傳送內容給用戶端時。Occurs just before ASP.NET sends content to the client.

PreSendRequestHeaders

正好發生於 ASP.NET 傳送 HTTP 標頭給用戶端時。Occurs just before ASP.NET sends HTTP headers to the client.

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

已經釋放與要求相關聯之 Managed 物件時發生。Occurs when the managed objects that are associated with the request have been released.

ResolveRequestCache

發生於 ASP.NET 完成授權事件,讓快取模組服務來自快取的要求,並略過事件處理常式 (例如,網頁或 XML Web Service) 的執行時。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

發生於 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)

啟始對 HTTP 事件處理常式的非同步呼叫。Initiates an asynchronous call to the HTTP event handler.

IHttpAsyncHandler.EndProcessRequest(IAsyncResult)

處理序完成時,提供非同步處理序 End 方法。Provides an asynchronous process End method when the process finishes.

IHttpHandler.IsReusable

取得 Boolean 值,指出另一個要求是否可以使用 IHttpHandler 物件。Gets a Boolean value indicating whether another request can use the IHttpHandler object.

IHttpHandler.ProcessRequest(HttpContext)

以實作 IHttpHandler 介面的自訂 HTTP 處理常式,來啟用 HTTP Web 要求的處理。Enables processing of HTTP Web requests by a custom HTTP handler that implements the IHttpHandler interface.

適用於

另請參閱