RequestNotification Перечисление
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Указывает, когда происходят события и другие события жизненного цикла во время обработки HttpApplication запроса.
Это перечисление поддерживает побитовую комбинацию значений его членов.
public enum class RequestNotification
[System.Flags]
public enum RequestNotification
[<System.Flags>]
type RequestNotification =
Public Enum RequestNotification
- Наследование
- Атрибуты
Поля
| Имя | Значение | Описание |
|---|---|---|
| BeginRequest | 1 | Указывает, что BeginRequest событие было создано для запроса и обрабатывается. |
| AuthenticateRequest | 2 | Указывает, что AuthenticateRequest событие было создано для запроса и обрабатывается. |
| AuthorizeRequest | 4 | Указывает, что AuthorizeRequest событие было создано для запроса и обрабатывается. |
| ResolveRequestCache | 8 | Указывает, что ResolveRequestCache событие было создано для запроса и обрабатывается. |
| MapRequestHandler | 16 | Указывает, что MapRequestHandler событие было создано для запроса и обрабатывается. |
| AcquireRequestState | 32 | Указывает, что AcquireRequestState событие было создано для запроса и обрабатывается. |
| PreExecuteRequestHandler | 64 | Указывает точку жизненного цикла приложения непосредственно перед обработчиком, обрабатывающим запрос. |
| ExecuteRequestHandler | 128 | Указывает, что обработчик, сопоставленный с запрошенным ресурсом, вызывается для обработки запроса. |
| ReleaseRequestState | 256 | Указывает, что ReleaseRequestState событие было создано для запроса и обрабатывается. |
| UpdateRequestCache | 512 | Указывает, что UpdateRequestCache событие было создано для запроса и обрабатывается. |
| LogRequest | 1024 | Указывает, что LogRequest событие было создано для запроса и обрабатывается. |
| EndRequest | 2048 | Указывает, что EndRequest событие было создано для запроса и обрабатывается. |
| SendResponse | 536870912 | Указывает, что обработка запроса завершена и отправляется ответ. |
Примеры
В следующем примере показано, как использовать 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. Дополнительные сведения см. в разделе "Версии и зависимости".