• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 308
  • Last Modified:

Returning http error codes with MFC isapi extension

I'm writing an MFC isapi extension, running in IIS 5.0, Windows 2000.
How can I return HTTP error code (such as 404, 500 etc) in the HTTP header to the HTTP client.

Thanks,
Michael.
0
bachar
Asked:
bachar
1 Solution
 
migelCommented:
Hi!
to do that you have to write some extra call in the your
HttpExtensionProc
for example:
DWORD CMyExtension::HttpExtensionProc( EXTENSION_CONTROL_BLOCK *pECB ){

if (....) // some conditions
{
// Raize Access denied error
          pECB->dwHttpStatusCode=HTTP_STATUS_AUTH_REQUIRED;
          strcpy(pECB->lpszLogData,"WWW-Authenticate: Basic Realm=\"Secure\"\r\n\r\n");

          size = lstrlen ( pECB->lpszLogData);
          pECB -> ServerSupportFunction ( pECB->ConnID,
                                        HSE_REQ_SEND_RESPONSE_HEADER,
                                        "401 Access Denied",
                                        &size,
                                        (LPDWORD) pECB->lpszLogData );
         
          return HSE_STATUS_ERROR;
}
}
 
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now