无法从网络配置中读取自定义部分

时间:2015-11-18 13:26:54

标签: c# web-config custom-sections

为什么我无法通过网络配置阅读此内容?当我使用App.config它工作正常..

  

FundGroups = null

private static readonly NameValueCollection FundGroups =
        (NameValueCollection)ConfigurationManager.GetSection("FundGroups");

的Web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>

<configSections>
    <section name="FundGroups" type="System.Configuration.NameValueSectionHandler" />
</configSections>

<FundGroups>
<add key="Group1" value="Value1" />
<add key="Group2" value="Value2" />
<add key="Group3" value="Value3" />
<add key="Group4" value="Value4" />
<add key="Group5" value="Value5" />
<add key="Group6" value="Value6" />
<add key="Group7" value="Value7" />
</FundGroups>


</configuration>

我发现可能有重复here。但是ConfigurationSettings.GetConfig似乎已经过时了,对我来说不起作用

0 个答案:

没有答案