Monday, August 13, 2012

How to store a dictionary object in web.config?

<configuration>
  <configSections>
    <section
      name="MyDictionary" type="System.Configuration.NameValueFileSectionHandler,System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </configSections>
  <MyDictionary>
     <add key="name1" value="value1" />
     <add key="name2" value="value2" />
  </MyDictionary>
</configuration>
NameValueCollection section = (NameValueCollection)ConfigurationManager.GetSection("MyDictionary");

No comments:

Post a Comment