如何阅读system.webserver配置部分? [英] How to read system.webserver configuration section?

查看:187
本文介绍了如何阅读system.webserver配置部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有'好'的方式使用WebConfigurationManagerØ任何读取IIS7的配置部分群体?
我试图读取授权部分,但WebConfigurationManager.GetSection()返回一个IgnoredSection实例。
这是我的code样子...

  authSection = WebConfigurationManager.GetSection(system.webServer /安全/授权,HttpContext.Current.Request.Path)


解决方案

 配置webConfig = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
的ConfigurationSection CS = webConfig.GetSection(system.webServer);
如果(CS!= NULL)
{
    的XDocument XML = XDocument.Load(新StringReader(cs.SectionInformation.GetRawXml()));
    ...
}

Is there any 'nice' way to read configuration section group of IIS7 by using WebConfigurationManager o anything? I tried to read the authorization section but WebConfigurationManager.GetSection() returns an 'IgnoredSection' instance. This is what my code looks like...

authSection = WebConfigurationManager.GetSection("system.webServer/security/authorization", HttpContext.Current.Request.Path)

解决方案

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

这篇关于如何阅读system.webserver配置部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆