IHttpServer::NotifyConfigurationChange, méthode
Déclenche une notification indiquant qu’un chemin de configuration a changé.
Syntaxe
virtual VOID NotifyConfigurationChange(
PCWSTR pszPath
) = 0;
Paramètres
pszPath
Pointeur vers une chaîne qui contient le chemin de configuration.
Valeur renvoyée
VOID
.
Remarques
IIS 7 déclenche automatiquement une notification GL_CONFIGURATION_CHANGE lorsque le fichier ApplicationHost.config est modifié. Les développeurs peuvent utiliser la NotifyConfigurationChange
méthode pour déclencher manuellement une GL_CONFIGURATION_CHANGE
notification pour le chemin de configuration spécifié dans le pszPath
paramètre.
Notes
Les développeurs peuvent utiliser la méthode CGlobalModule::OnGlobalConfigurationChange pour fournir un traitement supplémentaire lorsqu’une GL_CONFIGURATION_CHANGE
notification se produit.
Exemple
L’exemple de code suivant montre comment utiliser la NotifyConfigurationChange
méthode pour créer un module HTTP qui déclenche manuellement une GL_CONFIGURATION_CHANGE
notification pour le chemin de configuration MACHINE/WEBROOT/APPHOST/Site web par défaut.
#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( pHttpContext );
UNREFERENCED_PARAMETER( pProvider );
g_pHttpServer->NotifyConfigurationChange(
L"MACHINE/WEBROOT/APPHOST/Default Web Site");
// 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 priority.
HRESULT hr = pModuleInfo->SetPriorityForRequestNotification(
RQ_BEGIN_REQUEST,PRIORITY_ALIAS_MEDIUM);
// Test for an error and exit if necessary.
if (FAILED(hr))
{
return hr;
}
// Set the request notifications and exit.
return pModuleInfo->SetRequestNotifications(
new MyHttpModuleFactory,
RQ_BEGIN_REQUEST,
0
);
}
Votre module doit exporter la fonction RegisterModule . Vous pouvez exporter cette fonction en créant un fichier de définition de module (.def) pour votre projet, ou vous pouvez compiler le module à l’aide du /EXPORT:RegisterModule
commutateur. Pour plus d’informations, consultez Procédure pas à pas : création d’un module HTTP Request-Level à l’aide de code natif.
Vous pouvez éventuellement compiler le code à l’aide de la __stdcall (/Gz)
convention d’appel au lieu de déclarer explicitement la convention d’appel pour chaque fonction.
Spécifications
Type | Description |
---|---|
Client | - IIS 7.0 sur Windows Vista - IIS 7.5 sur Windows 7 - IIS 8.0 sur Windows 8 - IIS 10.0 sur Windows 10 |
Serveur | - IIS 7.0 sur Windows Server 2008 - IIS 7.5 sur Windows Server 2008 R2 - IIS 8.0 sur Windows Server 2012 - IIS 8.5 sur Windows Server 2012 R2 - IIS 10.0 sur Windows Server 2016 |
Produit | - 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 |
En-tête | Httpserv.h |
Voir aussi
IHttpServer Interface
CGlobalModule::OnGlobalConfigurationChange, méthode
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour