| title | IHttpEventProvider::SetErrorStatus Method |
|---|---|
| description | Learn how the SetErrorStatus method specifies an error to return. |
| ms.date | 10/07/2016 |
| ms.assetid | 62f84393-a0b2-32f6-6f80-6db3ada4378a |
Specifies an error to return.
virtual VOID SetErrorStatus(
IN HRESULT hrError
) = 0; hrError
[IN] An HRESULT that contains the error to specify.
VOID.
The SetErrorStatus method does not directly affect request processing, but it can be used to indicate the reason for a failure to IIS or other modules. For example, if a module that you have written traps an error, the module can set the error status for the request and return processing to the integrated request-processing pipeline so that other modules can process the error.
The following code example demonstrates how to create an HTTP module that sends an example string to the Web client and captures the return value from this operation. The module uses the SetErrorStatus method to specify the return value as the error status for the current request and then exits.
[!code-cppIHttpEventProviderSetErrorStatus#1]
Your module must export the RegisterModule function. You can export this function by creating a module definition (.def) file for your project, or you can compile the module by using the /EXPORT:RegisterModule switch. For more information, see Walkthrough: Creating a Request-Level HTTP Module By Using Native Code.
You can optionally compile the code by using the __stdcall (/Gz) calling convention instead of explicitly declaring the calling convention for each function.
| Type | Description |
|---|---|
| Client | - IIS 7.0 on [!INCLUDEwinvista] - IIS 7.5 on Windows 7 - IIS 8.0 on Windows 8 - IIS 10.0 on Windows 10 |
| Server | - IIS 7.0 on [!INCLUDEwinsrv2008] - 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 - [!INCLUDEiisexp75], [!INCLUDEiisexp80], [!INCLUDEiisexp100] |
| Header | Httpserv.h |