RequestNotification Wyliczenie

Definicja

Wskazuje, kiedy zdarzenia i inne zdarzenia cyklu życia występują podczas przetwarzania HttpApplication żądania.

To wyliczenie obsługuje bitową kombinację jego wartości składowych.

public enum class RequestNotification
[System.Flags]
public enum RequestNotification
[<System.Flags>]
type RequestNotification = 
Public Enum RequestNotification
Dziedziczenie
RequestNotification
Atrybuty

Pola

AcquireRequestState 32

Wskazuje, że AcquireRequestState zdarzenie zostało zgłoszone dla żądania i jest przetwarzane.

AuthenticateRequest 2

Wskazuje, że AuthenticateRequest zdarzenie zostało zgłoszone dla żądania i jest przetwarzane.

AuthorizeRequest 4

Wskazuje, że AuthorizeRequest zdarzenie zostało zgłoszone dla żądania i jest przetwarzane.

BeginRequest 1

Wskazuje, że BeginRequest zdarzenie zostało zgłoszone dla żądania i jest przetwarzane.

EndRequest 2048

Wskazuje, że EndRequest zdarzenie zostało zgłoszone dla żądania i jest przetwarzane.

ExecuteRequestHandler 128

Wskazuje, że program obsługi mapowany na żądany zasób jest wywoływany w celu przetworzenia żądania.

LogRequest 1024

Wskazuje, że LogRequest zdarzenie zostało zgłoszone dla żądania i jest przetwarzane.

MapRequestHandler 16

Wskazuje, że MapRequestHandler zdarzenie zostało zgłoszone dla żądania i jest przetwarzane.

PreExecuteRequestHandler 64

Wskazuje punkt w cyklu życia aplikacji tuż przed program obsługi, który przetwarza żądanie jest mapowany.

ReleaseRequestState 256

Wskazuje, że ReleaseRequestState zdarzenie zostało zgłoszone dla żądania i jest przetwarzane.

ResolveRequestCache 8

Wskazuje, że ResolveRequestCache zdarzenie zostało zgłoszone dla żądania i jest przetwarzane.

SendResponse 536870912

Wskazuje, że przetwarzanie żądania zostało ukończone i że odpowiedź jest wysyłana.

UpdateRequestCache 512

Wskazuje, że UpdateRequestCache zdarzenie zostało zgłoszone dla żądania i jest przetwarzane.

Przykłady

W poniższym przykładzie pokazano, jak za pomocą RequestNotification wyliczenia z właściwością CurrentNotification określić, które zdarzenie bieżącego HttpApplication wystąpienia przetwarza żądanie.

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

Uwagi

Wyliczenie RequestNotification jest używane z właściwością CurrentNotificationHttpContext klasy w celu określenia, jakie zdarzenie w potoku jest obecnie przetwarzane. Aby określić, kiedy wszystkie programy obsługi dla określonego HttpApplication zdarzenia wystąpienia zakończyły przetwarzanie, użyj IsPostNotification właściwości .

Typ RequestNotification jest wprowadzany w .NET Framework 3.5. Aby uzyskać więcej informacji, zobacz Wersje i zależności.

Dotyczy

Zobacz też