如何阅读system.webserver配置部分?

Max*_*ean 10 asp.net iis-7 configurationsection

是否有任何"好的"方法通过使用WebConfigurationManager来读取IIS7的配置节组?我试图读取授权部分,但WebConfigurationManager.GetSection()返回一个'IgnoredSection'实例.这就是我的代码看起来像......

authSection = WebConfigurationManager.GetSection("system.webServer/security/authorization", HttpContext.Current.Request.Path)
Run Code Online (Sandbox Code Playgroud)

ale*_*lex 7

Configuration webConfig = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath); 
ConfigurationSection cs = webConfig.GetSection("system.webServer");
if (cs != null)
{
    XDocument xml = XDocument.Load(new StringReader(cs.SectionInformation.GetRawXml()));
    ...
}
Run Code Online (Sandbox Code Playgroud)