HttpContext.CurrentNotification 속성

정의

현재 처리 중인 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

속성 값

RequestNotification 값 중 하나입니다.One of the RequestNotification values.

예외

이 작업에 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. 대신 ASP.NET 파이프라인에서 요청을 처리 하는 동안 IIS 7.0IIS 7.0에 의해 설정 됩니다.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.

적용 대상

추가 정보