다음을 통해 공유


CHttpModule::OnMapPath 메서드

작업이 현재 요청에 매핑할 실제 경로를 요청할 때 발생하는 이벤트를 처리 MapPath 할 메서드를 나타냅니다.

구문

virtual REQUEST_NOTIFICATION_STATUS OnMapPath(  
   IN IHttpContext* pHttpContext,  
   IN IMapPathProvider* pProvider  
);  

매개 변수

pHttpContext
[IN] IHttpContext 인터페이스에 대한 포인터입니다.

pProvider
[IN] IMapPathProvider 인터페이스에 대한 포인터입니다.

반환 값

REQUEST_NOTIFICATION_STATUS 값입니다.

설명

RQ_MAP_PATH 알림에 대해 요청 수준 모듈이 등록되면 작업에서 현재 요청에 매핑할 실제 경로를 요청할 때 IIS는 모듈의 OnMapPath 메서드를 호출합니다.

참고

요청 수준 모듈은 모듈의 RegisterModule 함수에 등록 RQ_MAP_PATH 하여 이벤트 알림에 등록할 수 있습니다MapPath.

예제

다음 코드 예제에서는 이벤트 알림에 등록 하는 요청 수준 HTTP 모듈을 RQ_MAP_PATH 만드는 방법을 보여 줍니다. 작업이 현재 요청에 매핑할 실제 경로를 요청하면 IIS는 예제 모듈의 OnMapPath 메서드를 호출합니다.

//  Insert data from ostringstream into the response
//  On error, Provider error status set here
//  ostringstream  buffer cleared for next call 

HRESULT  WECbyRefChunk( std::ostringstream  &os, IHttpContext *pHttpContext, 
                       IHttpEventProvider *pProvider, LONG InsertPosition= -1)
{
    HRESULT hr = S_OK;

    IHttpTraceContext * pTraceContext = pHttpContext->GetTraceContext();

    hr = pTraceContext->QuickTrace(L"WECbyRefChunk",L"data 2",E_FAIL,6);
    if (FAILED(hr)){
        LOG_ERR_HR(hr,"QuickTrace");
        return hr;
    }
    // create convenience string from ostringstream  
    std::string str(os.str());

    HTTP_DATA_CHUNK dc;
    dc.DataChunkType = HttpDataChunkFromMemory;
    dc.FromMemory.BufferLength = static_cast<DWORD>(str.size());
    dc.FromMemory.pBuffer = pHttpContext->AllocateRequestMemory( 
        static_cast<DWORD>( str.size()+1) );

    if(!dc.FromMemory.pBuffer){
        hr = HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
        LOG_ERR_HR(hr,"AllocateRequestMemory");
        pProvider->SetErrorStatus(hr);
        return hr;
    }

    //  use char pointer p for convenience
    char *p = static_cast<char *>(dc.FromMemory.pBuffer);
    strcpy_s(p, str.size()+1, str.c_str());

    hr = pHttpContext->GetResponse()->WriteEntityChunkByReference( 
        &dc, InsertPosition );

    if (FAILED(hr)){
        LOG_ERR_HR(hr,"AllocateRequestMemory");
        pProvider->SetErrorStatus( hr );
    }

    os.str("");                // clear the ostringstream for next call

    return hr;
}  

요구 사항

형식 Description
클라이언트 - Windows Vista의 IIS 7.0
- Windows 7의 IIS 7.5
- Windows 8의 IIS 8.0
- WINDOWS 10 IIS 10.0
서버 - Windows Server 2008의 IIS 7.0
- Windows Server 2008 R2의 IIS 7.5
- Windows Server 2012의 IIS 8.0
- Windows Server 2012 R2의 IIS 8.5
- WINDOWS SERVER 2016 IIS 10.0
제품 - 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
헤더 Httpserv.h

참고 항목

CHttpModule 클래스