RequestNotification 列挙型

定義

HttpApplication 要求の処理中にイベントおよびその他のライフ サイクル イベントがどの時点で発生するかを示します。

この列挙体は、メンバー値のビットごとの組み合わせをサポートしています。

public enum class RequestNotification
[System.Flags]
public enum RequestNotification
[<System.Flags>]
type RequestNotification = 
Public Enum RequestNotification
継承
RequestNotification
属性

フィールド

AcquireRequestState 32

要求に対して AcquireRequestState イベントが発生し、要求を処理していることを示します。

AuthenticateRequest 2

要求に対して AuthenticateRequest イベントが発生し、要求を処理していることを示します。

AuthorizeRequest 4

要求に対して AuthorizeRequest イベントが発生し、要求を処理していることを示します。

BeginRequest 1

要求に対して BeginRequest イベントが発生し、要求を処理していることを示します。

EndRequest 2048

要求に対して EndRequest イベントが発生し、要求を処理していることを示します。

ExecuteRequestHandler 128

要求されたリソースに対応付けられたハンドラーが要求を処理するために呼び出されていることを示します。

LogRequest 1024

要求に対して LogRequest イベントが発生し、要求を処理していることを示します。

MapRequestHandler 16

要求に対して MapRequestHandler イベントが発生し、要求を処理していることを示します。

PreExecuteRequestHandler 64

要求を処理するハンドラーが対応付けられている、アプリケーション ライフ サイクル中の直前の時点を示します。

ReleaseRequestState 256

要求に対して ReleaseRequestState イベントが発生し、要求を処理していることを示します。

ResolveRequestCache 8

要求に対して ResolveRequestCache イベントが発生し、要求を処理していることを示します。

SendResponse 536870912

要求の処理が完了し、応答が送信されていることを示します。

UpdateRequestCache 512

要求に対して UpdateRequestCache イベントが発生し、要求を処理していることを示します。

次の例では、 RequestNotification プロパティで 列挙を使用して、 CurrentNotification 現在 HttpApplication のインスタンスのどのイベントが要求を処理しているかを判断する方法を示します。

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

注釈

RequestNotification列挙は、 クラスの プロパティと共CurrentNotificationHttpContext使用され、パイプラインで現在処理されているイベントを決定します。 インスタンスの特定のイベントのすべてのハンドラーが処理を終了したタイミングを HttpApplication 確認するには、 プロパティを IsPostNotification 使用します。

型はRequestNotification、.NET Framework 3.5 で導入されています。 詳細については、「.NET Framework のバージョンおよび依存関係」を参照してください。

適用対象

こちらもご覧ください