CHttpServer::SendErrorResponse Method  
 
BOOL SendErrorResponse(
  UINT nClientId,  
  UINT nErrorCode,  
  LPCTSTR lpszMessage  
);

Send a customized error response to the specified client.

Parameters

nClientId
An unsigned integer which uniquely identifies the client session.
nErrorCode
An integer value that specifies the error code that should be sent to the client. This value should correspond to the error result codes defined for HTTP in RFC 2616, which are three-digit values in the range of 400 through 599. The method will fail if an invalid error code is specified.
lpszMessage
A null-terminated string that describes the error. If this parameter is NULL or specifies a zero-length string, a default message will be selected based on the error code.

Return Value

If the method succeeds, the return value is non-zero. If the method fails, the return value is zero. To get extended error information, call the GetLastError method.

Remarks

The SendErrorResponse method sends a response to the client indicating that an error has occurred, providing a numeric error code and HTML formatted text which may be displayed to the user. The lpszMessage parameter should provide a brief description of the error that will be included in the output sent to the client. Note that the message should not contain any special formatting control characters or HTML markup.

This method provides a simplified interface for sending an error response to the client. In some cases, a browser may choose to display its own error message to the user in place of the generic HTML document generated by this method. If you want your application to send a customized HTML document for a specific type of error, you should use the SendResponse method.

If you wish to redirect the client to use an alternate URL to access the requested resource, it is recommended that you use the RedirectRequest method rather than sending an error response.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools11.h
Import Library: cshtsv11.lib
Unicode: Implemented as Unicode and ANSI versions

See Also

RedirectRequest, SendResponse