HttpContext.CurrentNotification HttpContext.CurrentNotification HttpContext.CurrentNotification HttpContext.CurrentNotification Property

정의

현재 처리 중인 HttpApplication 이벤트를 나타내는 RequestNotification 값을 가져옵니다.Gets a RequestNotification value that indicates the current HttpApplication event that is processing.

public:
 property System::Web::RequestNotification CurrentNotification { System::Web::RequestNotification get(); };
public System.Web.RequestNotification CurrentNotification { get; }
member this.CurrentNotification : System.Web.RequestNotification
Public ReadOnly Property CurrentNotification As RequestNotification

속성 값

예외

이 작업에 IIS 7.0IIS 7.0의 통합 파이프라인 모드와 .NET Framework 버전 3.0 이상이 필요합니다.The operation requires integrated pipeline mode in IIS 7.0IIS 7.0 and at least the .NET Framework version 3.0.

예제

다음 예제에 사용 하는 방법을 보여 줍니다.는 CurrentNotification 속성의 이벤트를 확인 하는 HttpApplication 현재 요청을 처리 하는 개체를 처리 합니다.The following example demonstrates how to use the CurrentNotification property to determine what event of the HttpApplication object that is handling the current request is being processed. 예제에서는 이벤트 처리기의 몇 가지 이벤트를 처리 합니다 HttpApplication 개체 및 CurrentNotification 속성 처리 중인 각 이벤트에 대 한 코드는 호출을 결정 합니다.In the example, the event handler handles several events of the HttpApplication object, and the CurrentNotification property determines what code is invoked for each event being handled.

using System;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;

// Module that demonstrates one event handler for several events.
namespace Samples
{
    public class ModuleExampleTestCS : IHttpModule
    {
        public ModuleExampleTestCS()
        {
            // Constructor
        }
        public void Init(HttpApplication app)
        {
            app.AuthenticateRequest += new EventHandler(App_Handler);
            app.PostAuthenticateRequest += new EventHandler(App_Handler);
            app.LogRequest += new EventHandler(App_Handler);
            app.PostLogRequest += new EventHandler(App_Handler);
        }
        public void Dispose()
        {
        }
        // One handler for AuthenticationRequest, PostAuthenticateRequest,
    // LogRequest, and PostLogRequest events
        public void App_Handler(object source, EventArgs e)
        {
            HttpApplication app = (HttpApplication)source;
            HttpContext context = app.Context;

            if (context.CurrentNotification == RequestNotification.AuthenticateRequest)
            {

                if (!context.IsPostNotification)
                {
                    // Put code here that is invoked when the AuthenticateRequest event is raised.
                }
                else
                {
                    // PostAuthenticateRequest 
                    // Put code here that runs after the AuthenticateRequest event completes.
                }
            }
            if (context.CurrentNotification == RequestNotification.LogRequest)
            {
                if (!context.IsPostNotification)
                {
                    // Put code here that is invoked when the LogRequest event is raised.
                }
                else
                {
                    // PostLogRequest
                    // Put code here that runs after the LogRequest event completes.
                }
            }

        }
    }
}
Imports System.Data
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI

' Module that demonstrates one event handler for several events.
Namespace Samples

    Public Class ModuleExampleTestVB
        Implements IHttpModule

        Public Sub New()
            ' Constructor
        End Sub

        Public Sub Init(ByVal app As HttpApplication) Implements IHttpModule.Init
            AddHandler app.AuthenticateRequest, AddressOf Me.App_Handler
            AddHandler app.PostAuthenticateRequest, AddressOf Me.App_Handler
            AddHandler app.LogRequest, AddressOf Me.App_Handler
            AddHandler app.PostLogRequest, AddressOf Me.App_Handler
        End Sub

        Public Sub Dispose() Implements IHttpModule.Dispose
        End Sub

        ' One handler for AuthenticationRequest, PostAuthenticateRequest,
    ' LogRequest, and PostLogRequest events
        Public Sub App_Handler(ByVal source As Object, ByVal e As EventArgs)
            Dim app As HttpApplication = CType(source, HttpApplication)
            Dim context As HttpContext = app.Context

            If (context.CurrentNotification = RequestNotification.AuthenticateRequest) Then

                If Not (context.IsPostNotification) Then

                    ' Put code here that is invoked when the AuthenticateRequest event is raised.
                Else

                    ' PostAuthenticateRequest 
                    ' Put code here that runs after the AuthenticateRequest event completes.

                End If
            End If

            If (context.CurrentNotification = RequestNotification.LogRequest) Then

                If Not (context.IsPostNotification) Then

                    ' Put code here that is invoked when the LogRequest event is raised.

                Else
                    ' PostLogRequest
                    ' Put code here that runs after the LogRequest event completes.

                End If
            End If
        End Sub
    End Class

End Namespace

설명

합니다 CurrentNotification 속성의 통합된 파이프라인 모드가 필요한 IIS 7.0IIS 7.0 이상.NET Framework 버전 3.0입니다.The CurrentNotification property requires the integrated pipeline mode in IIS 7.0IIS 7.0 and at least the .NET Framework version 3.0. 사용 가능한 경우 속성은 반환 된 RequestNotification 값입니다.When available, the property returns a RequestNotification value. 값을 CurrentNotification 속성에서 이벤트를 나타냅니다는 HttpApplication 인스턴스는 요청을 처리 하 고 현재.The value of the CurrentNotification property indicates which event in the HttpApplication instance is currently processing the request.

CurrentNotification 속성은 설정할 수 없습니다.The CurrentNotification property is not intended to be set. 대신에 의해 설정 된 IIS 7.0IIS 7.0 ASP.NET 파이프라인에서 요청을 처리 하는 중입니다.Instead, it is set by IIS 7.0IIS 7.0 during the processing of the request in the ASP.NET pipeline. 설정 된 CurrentNotification 속성 컴파일 오류가 발생 합니다.Setting the CurrentNotification property will result in a compilation error.

CurrentNotification .NET Framework 버전 3.5에서에서 도입 되었습니다.CurrentNotification is introduced in the .NET Framework version 3.5. 자세한 내용은 버전 및 종속성을 참조하세요.For more information, see Versions and Dependencies.

적용 대상

추가 정보