cant read custom section from web config

312 Views Asked by At

Why can't I read this from my web config? When I used App.config it worked fine..

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>

I found a possible duplication here. But the ConfigurationSettings.GetConfig seems to be obsolete and doesnt work for me

0

There are 0 best solutions below