private static void ValidateTheWebApplicationInitialiserModuleIsIncluded(HttpApplication app)
{
object webServerSection = ConfigurationManager.GetSection("system.webServer");
var sect = webServerSection as IgnoreSection;
sect.SectionInformation.GetRawXml();
bool hasModule = false;
//if not iis 7 integrated mode
HttpModulesSection httpModulesSection =
ConfigurationManager.GetSection("system.web/httpModules") as HttpModulesSection;
foreach (HttpModuleAction module in httpModulesSection.Modules)
{
if (module.Type.Contains(typeof(WebApplicationInitialiserModule).Name))
hasModule = true;
}
// if iis 6 or iis 7 classic mode
// throw exception if the module hasn't been found
if (hasModule == false)
throw new Exception("The webinitialiser requires the WebApplicationInitialisationModule to be added to the web.config to operate correctly. Please add the module before any other modules");
}