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.
Recycelt eine Anwendung.
Syntax
virtual VOID RecycleApplication(
PCWSTR pszAppConfigPath
) = 0;
Parameter
pszAppConfigPath
Ein Zeiger auf eine Zeichenfolge, die den Zuverwendenden Konfigurationspfad enthält.
Rückgabewert
VOID.
Bemerkungen
Die RecycleApplication -Methode fordert eine Wiederverwendung der Anwendung an, die durch den Konfigurationspfad im pszAppConfigPath Parameter angegeben wird. Beispielsweise ähnelt der Konfigurationspfad für die Standardwebsite auf einem Server mit IIS 7 in der Regel MACHINE/WEBROOT/APPHOST/Standardwebsite.
Hinweis
Sie können den Konfigurationspfad mithilfe der IHttpApplication::GetAppConfigPath-Methode abrufen.
Beispiel
Im folgenden Codebeispiel wird veranschaulicht, wie Sie ein HTTP-Modul erstellen, das die Methoden IHttpApplication::GetAppConfigPath und RecycleApplication verwendet, um die verwaltete Anwendung abzurufen und zu recyceln, die die aktuelle Anforderung verarbeitet.
#define _WINSOCKAPI_
#include <windows.h>
#include <sal.h>
#include <httpserv.h>
// Create a pointer for the global server interface.
IHttpServer * g_pHttpServer = NULL;
// Create the module class.
class MyHttpModule : public CHttpModule
{
public:
REQUEST_NOTIFICATION_STATUS
OnBeginRequest(
IN IHttpContext * pHttpContext,
IN IHttpEventProvider * pProvider
)
{
UNREFERENCED_PARAMETER( pProvider );
// Test for an error.
if (NULL != g_pHttpServer)
{
// Retrieve a pointer to the IHttpApplication class.
IHttpApplication * pHttpApplication = pHttpContext->GetApplication();
// Test for an error.
if (NULL != pHttpApplication)
{
// Restart the application based on the configuration path.
g_pHttpServer->RecycleApplication(pHttpApplication->GetAppConfigPath());
}
}
// 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 );
// Store the pointer for the global server interface.
g_pHttpServer = pGlobalInfo;
// Set the request notifications and exit.
return pModuleInfo->SetRequestNotifications(
new MyHttpModuleFactory,
RQ_BEGIN_REQUEST,
0
);
}
Ihr Modul muss die Funktion RegisterModule 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 /EXPORT:RegisterModule Switches 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) aufrufende Konvention verwenden, anstatt die aufrufende Konvention 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 auf 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 auf 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
IHttpApplication::GetAppConfigPath-Methode
IHttpServer-Schnittstelle
IHttpServer::RecycleProcess-Methode