Condividi tramite


enumerazione REQUEST_NOTIFICATION_STATUS

Definisce i valori restituiti per le notifiche a livello di richiesta.

Sintassi

typedef enum REQUEST_NOTIFICATION_STATUS{  
   RQ_NOTIFICATION_CONTINUE,  
   RQ_NOTIFICATION_PENDING,  
   RQ_NOTIFICATION_FINISH_REQUEST  
};  

Members

Nome del membro Descrizione
RQ_NOTIFICATION_CONTINUE Indica che IIS deve continuare a elaborare notifiche aggiuntive a livello di richiesta.
RQ_NOTIFICATION_PENDING Indica che una notifica asincrona è in sospeso e restituisce l'elaborazione a livello di richiesta in IIS.
RQ_NOTIFICATION_FINISH_REQUEST Indica che IIS ha completato l'elaborazione delle notifiche a livello di richiesta e non deve elaborare notifiche aggiuntive a livello di richiesta.

Commenti

I membri dell'enumerazione REQUEST_NOTIFICATION_STATUS vengono usati come valori restituiti dalle notifiche a livello di richiesta e i membri consentono di controllare il flusso del processo all'interno della pipeline integrata di elaborazione delle richieste. Ad esempio, la restituzione RQ_NOTIFICATION_CONTINUE da un gestore di notifica a livello di richiesta indica a IIS di continuare a elaborare notifiche aggiuntive a livello di richiesta, mentre la restituzione RQ_NOTIFICATION_FINISH_REQUEST da un gestore di notifica a livello di richiesta informa IIS che l'elaborazione a livello di richiesta è completa e IIS non deve elaborare notifiche aggiuntive a livello di richiesta. I moduli che implementano la gestione delle richieste devono restituire RQ_NOTIFICATION_FINISH_REQUEST quando si verifica un errore.

Esempio

Nell'esempio seguente viene implementato un RQ_BEGIN_REQUEST gestore. Se la richiesta non è un file HTML, l'esempio restituisce RQ_NOTIFICATION_CONTINUE e si verifica la normale elaborazione. Quando il valore del contatore ha un resto zero, il file richiesto viene sostituito da una stringa restituita dal metodo IHttpResponse::WriteEntityChunkByReference e l'esempio restituisce RQ_NOTIFICATION_FINISH_REQUEST. Se si verifica un errore, l'esempio registra l'errore e restituisce 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;
}

Requisiti

Tipo Descrizione
Client - IIS 7.0 in Windows Vista
- IIS 7.5 in Windows 7
- IIS 8.0 in Windows 8
- IIS 10.0 in Windows 10
Server - IIS 7.0 in Windows Server 2008
- IIS 7.5 in Windows Server 2008 R2
- IIS 8.0 in Windows Server 2012
- IIS 8.5 in Windows Server 2012 R2
- IIS 10.0 in Windows Server 2016
Prodotto - 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
Intestazione Httpserv.h

Vedere anche

Enumerazione Web Server Core
enumerazione GLOBAL_NOTIFICATION_STATUS