The code I used to get the HTTP modules is basically
HttpModulesSection modules = ((SystemWebSectionGroup)config.GetSectionGroup("system.web")).HttpModules;
// Depending on what we need to do...
//modules.Modules.Add(CreateSomeModule());
//modules.Modules.Remove("SomeOtherModule");
This worked fine until IIS7. The migration command %SystemRoot%\system32\inetsrv\appcmd migrate config "website/"moves the modules to system.webServer, so my code now updates the wrong section.
Is there a built-in way to get the corresponding module section that needs to be changed? Or do I need to add a check for Request.ServerVariables ["SERVER_SOFTWARE"] and return system.web/ system.webServerdepending on the line I am returning?
source
share