REQUEST_NOTIFICATION_STATUS Enumeration

Defines the return values for request-level notifications.

Syntax

typedef enum REQUEST_NOTIFICATION_STATUS{  
   RQ_NOTIFICATION_CONTINUE,  
   RQ_NOTIFICATION_PENDING,  
   RQ_NOTIFICATION_FINISH_REQUEST  
};  

Members

Member name Description
RQ_NOTIFICATION_CONTINUE Indicates that IIS should continue processing additional request-level notifications.
RQ_NOTIFICATION_PENDING Indicates that an asynchronous notification is pending and returns request-level processing to IIS.
RQ_NOTIFICATION_FINISH_REQUEST Indicates that IIS has finished processing request-level notifications and should not process any additional request-level notifications.

Remarks

The members of the REQUEST_NOTIFICATION_STATUS enumeration are used as return values from request-level notifications, and the members help to control process flow within the integrated request-processing pipeline. For example, returning RQ_NOTIFICATION_CONTINUE from a request-level notification handler instructs IIS to continue processing additional request-level notifications, whereas returning RQ_NOTIFICATION_FINISH_REQUEST from a request-level notification handler informs IIS that request-level processing is complete and IIS should not process additional request-level notifications. Modules that implement request handling should return RQ_NOTIFICATION_FINISH_REQUEST when an error occurs.

Example

The following example implements a RQ_BEGIN_REQUEST handler. If the request is not an HTML file, the example returns RQ_NOTIFICATION_CONTINUE and normal processing occurs. When the counter value has a zero remainder, the requested file is replaced by a string returned by the IHttpResponse::WriteEntityChunkByReference method and the example returns RQ_NOTIFICATION_FINISH_REQUEST. If an error occurs, the example logs the error and returns RQ_NOTIFICATION_FINISH_REQUEST.

REQUEST_NOTIFICATION_STATUS
CMyHttpModule::OnBeginRequest(
    IHttpContext*       pHttpContext,
    IHttpEventProvider* pProvider
)
{
    HRESULT hr;

    static long cnt;
    InterlockedIncrement(&cnt);  // keep track of how many times we are called
    cnt++;

    IHttpRequest *pRequest = pHttpContext->GetRequest();
    PCWSTR url = pRequest->GetRawHttpRequest()->CookedUrl.pAbsPath;
    OutputDebugStringW(url);

    // return unless requesting a HTML file

    if (!wcsstr(url, L".htm"))
        return RQ_NOTIFICATION_CONTINUE;

    IHttpResponse * pHttpResponse = pHttpContext->GetResponse();

    // Return most times so we can still view content
    if ((cnt % 5) || pHttpResponse == NULL)
        return RQ_NOTIFICATION_CONTINUE;

    TRC_MSG_FULL("HTML  cnt = " << cnt);

    static int insertPosCnt;
    int insertPos = ++insertPosCnt % 2 - 1;    // toggle between 0 and -1

    // Use ostringstream to create some dynamic content
    std::ostringstream os;

    os << "<p /> first chunk  callback count = " << cnt
        << " insertPos = " << insertPos << "<br />";

    // 
    // WECbyRefChunk does all the work of inserting data into the response
    //

    hr = WECbyRefChunk(os, pHttpContext, pProvider, insertPos);
    if (FAILED(hr))
        return RQ_NOTIFICATION_FINISH_REQUEST;

    os << "<br /> <b> Adding 2nd chunk in Bold </b> File insertPos = " << insertPos;
    hr = WECbyRefChunk(os, pHttpContext, pProvider, insertPos);
    if (FAILED(hr))
        return RQ_NOTIFICATION_FINISH_REQUEST;

    os << " <p /> Last (3rd) Chunk added with default append chunk  GetCurrentThreadId = "
        << GetCurrentThreadId();

    // any errors will be logged/handled in  WECbyRefChunk
    WECbyRefChunk(os, pHttpContext, pProvider);

    // End additional processing, not because of error, but so another request
    // (from a GIF or .css style sheet on the same HTML page)
    // doesn't wipe out our WriteEntityChunkByReference. We can also get the
    // WriteEntityChunkByReference prepended to our normal HTML page. 

    return RQ_NOTIFICATION_FINISH_REQUEST;

}
HRESULT hr = S_OK;

IHttpTraceContext * pTraceContext = pHttpContext->GetTraceContext();
hr = My_Events::My_COMPLETION::RaiseEvent(pTraceContext, InsertPosition);
if (FAILED(hr)) {
    LOG_ERR_HR(hr, "RaiseEvent");
    return hr;
}

Requirements

Type Description
Client - IIS 7.0 on Windows Vista
- IIS 7.5 on Windows 7
- IIS 8.0 on Windows 8
- IIS 10.0 on Windows 10
Server - IIS 7.0 on Windows Server 2008
- IIS 7.5 on Windows Server 2008 R2
- IIS 8.0 on Windows Server 2012
- IIS 8.5 on Windows Server 2012 R2
- IIS 10.0 on Windows Server 2016
Product - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
- IIS Express 7.5, IIS Express 8.0, IIS Express 10.0
Header Httpserv.h

See Also

Web Server Core Enumerations
GLOBAL_NOTIFICATION_STATUS Enumeration