繁体   English   中英

有没有更好的方法从web.config获取正确的模块部分?

[英]Is there a better way to get the proper modules section from the web.config?

我用来获取HTTP模块的代码基本上就是这样

HttpModulesSection modules = ((SystemWebSectionGroup)config.GetSectionGroup("system.web")).HttpModules;
// Depending on what we need to do...
//modules.Modules.Add(CreateSomeModule());
//modules.Modules.Remove("SomeOtherModule");

在IIS7之前,这工作正常。 迁移命令%SystemRoot%\\system32\\inetsrv\\appcmd migrate config "website/"将模块移动到system.webServer ,因此我的代码现在正在更新错误的部分。

是否有内置方法来获取应修改的正确模块部分? 或者我是否必须添加对Request.ServerVariables [“SERVER_SOFTWARE”]的检查,并根据我收到的字符串返回system.web / system.webServer

HttpContext.Current.ApplicationInstance.Modules

这将返回一个HttpModuleCollection对象。 或者您想知道如何在运行时以编程方式注册HttpModules

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM