Expand Minimize

RequestNotification Enumeration

Indicates when events and other life-cycle events occur while a HttpApplication request is being processed.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)

[FlagsAttribute]
public enum RequestNotification

Member nameDescription
AcquireRequestStateIndicates that the AcquireRequestState event was raised for the request and is processing.
AuthenticateRequestIndicates that the AuthenticateRequest event was raised for the request and is processing.
AuthorizeRequestIndicates that the AuthorizeRequest event was raised for the request and is processing.
BeginRequestIndicates that the BeginRequest event was raised for the request and is processing.
EndRequestIndicates that the EndRequest event was raised for the request and is processing.
ExecuteRequestHandlerIndicates that the handler that is mapped to the requested resource is being invoked to process the request.
LogRequestIndicates that the LogRequest event was raised for the request and is processing.
MapRequestHandlerIndicates that the MapRequestHandler event was raised for the request and is processing.
PreExecuteRequestHandlerIndicates a point in the application life cycle just before the handler that processes the request is mapped.
ReleaseRequestStateIndicates that the ReleaseRequestState event was raised for the request and is processing.
ResolveRequestCacheIndicates that the ResolveRequestCache event was raised for the request and is processing.
SendResponseIndicates that processing of the request is complete and that the response is being sent.
UpdateRequestCacheIndicates that the UpdateRequestCache event was raised for the request and is processing.

The RequestNotification enumeration is used with the CurrentNotification property of the HttpContext class to determine what event in the pipeline is currently processing. To determine when all the handlers for a specific event of the HttpApplication instance have finished processing, use the IsPostNotification property.

The RequestNotification type is introduced in the .NET Framework 3.5. For more information, see .NET Framework Versions and Dependencies.

The following example shows how to use the RequestNotification enumeration with the CurrentNotification property to determine which event of the current HttpApplication instance is processing the request.

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.
                }
            }

        }
    }
}

.NET Framework

Supported in: 4.5, 4, 3.5 SP1, 3.0 SP1, 2.0 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft