I'm trying to find a way to programmatically check if a particular HttpModule is loaded (as a component I'm writing requires the module to work correctly). I'm trying:
bool ismodulepresent = false;
foreach(HttpModuleAction module in ((HttpModulesSection)ConfigurationManager.GetSection("system.web/httpModules")).Modules)
{
if(module.Type == typeof(MyModule).FullName)
{
ismodulepresent = true;
break;
}
}
But that only works for the IIS5.1 <httpModules>
section and not the newer <system.webServer>
section.
Any idea if there is a better way to do this other than just checking both sections?