Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Bricht alle ausstehenden Sende- oder Empfangsvorgänge ab.
Syntax
virtual HRESULT CancelIo(
VOID
) = 0;
Parameter
Diese Methode nimmt zwei Parameter entgegen.
Rückgabewert
HRESULT. Mögliches Werte (aber nicht die Einzigen) sind die in der folgenden Tabelle.
| Wert | BESCHREIBUNG |
|---|---|
| S_OK | Gibt an, dass der Vorgang erfolgreich war. |
| ERROR_INVALID_HANDLE | Gibt an, dass IIS kein asynchrones Handle für den Vorgang abrufen und sperren konnte. |
Bemerkungen
Die CancelIo -Methode beendet alle ausstehenden Sende- oder Empfangsvorgänge mit einem Webclient. Wenn beispielsweise ein HTTP-Modul Informationen vom Webclient liest, werden beim Aufrufen der CancelIo -Methode alle ausstehenden Lesevorgänge abgebrochen.
Diese Methode unterscheidet sich von den Methoden IHttpResponse::ResetConnection und IHttpResponse::SetNeedDisconnect , die die Socketverbindung mit einem Webclient sofort bzw. nach Abschluss der Antwort zurücksetzen.
Beispiel
Im folgenden Codebeispiel wird veranschaulicht, wie die CancelIo -Methode verwendet wird, um ein HTTP-Modul zu erstellen, das alle ausstehenden Sende- oder Empfangsvorgänge abbricht.
#define _WINSOCKAPI_
#include <windows.h>
#include <sal.h>
#include <httpserv.h>
// Create the module class.
class MyHttpModule : public CHttpModule
{
public:
REQUEST_NOTIFICATION_STATUS
OnSendResponse(
IN IHttpContext * pHttpContext,
IN ISendResponseProvider * pProvider
)
{
UNREFERENCED_PARAMETER( pProvider );
// Cancel any pending I/O operations.
pHttpContext->CancelIo();
// Return processing to the pipeline.
return RQ_NOTIFICATION_CONTINUE;
}
};
// Create the module's class factory.
class MyHttpModuleFactory : public IHttpModuleFactory
{
public:
HRESULT
GetHttpModule(
OUT CHttpModule ** ppModule,
IN IModuleAllocator * pAllocator
)
{
UNREFERENCED_PARAMETER( pAllocator );
// Create a new instance.
MyHttpModule * pModule = new MyHttpModule;
// Test for an error.
if (!pModule)
{
// Return an error if the factory cannot create the instance.
return HRESULT_FROM_WIN32( ERROR_NOT_ENOUGH_MEMORY );
}
else
{
// Return a pointer to the module.
*ppModule = pModule;
pModule = NULL;
// Return a success status.
return S_OK;
}
}
void Terminate()
{
// Remove the class from memory.
delete this;
}
};
// Create the module's exported registration function.
HRESULT
__stdcall
RegisterModule(
DWORD dwServerVersion,
IHttpModuleRegistrationInfo * pModuleInfo,
IHttpServer * pGlobalInfo
)
{
UNREFERENCED_PARAMETER( dwServerVersion );
UNREFERENCED_PARAMETER( pGlobalInfo );
// Set the request notifications and exit.
return pModuleInfo->SetRequestNotifications(
new MyHttpModuleFactory,
RQ_SEND_RESPONSE,
0
);
}
Ihr Modul muss die RegisterModule-Funktion exportieren. Sie können diese Funktion exportieren, indem Sie eine Moduldefinitionsdatei (.def) für Ihr Projekt erstellen, oder Sie können das Modul mithilfe des Schalters /EXPORT:RegisterModule kompilieren. Weitere Informationen finden Sie unter Exemplarische Vorgehensweise: Erstellen eines Request-Level HTTP-Moduls mithilfe von nativem Code.
Sie können den Code optional kompilieren, indem Sie die __stdcall (/Gz) Aufrufkonvention verwenden, anstatt die Aufrufkonvention für jede Funktion explizit zu deklarieren.
Anforderungen
| type | BESCHREIBUNG |
|---|---|
| Client | – IIS 7.0 unter Windows Vista – IIS 7.5 unter Windows 7 – IIS 8.0 unter Windows 8 – IIS 10.0 unter Windows 10 |
| Server | – IIS 7.0 unter Windows Server 2008 – IIS 7.5 unter Windows Server 2008 R2 – IIS 8.0 unter Windows Server 2012 – IIS 8.5 unter Windows Server 2012 R2 – IIS 10.0 unter Windows Server 2016 |
| Produkt | – 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 |
| Header | Httpserv.h |
Weitere Informationen
IHttpContext-Schnittstelle
IHttpResponse::ResetConnection-Methode
IHttpResponse::SetNeedDisconnect-Methode