1

Currently my app config settings are look like this

<appSettings>
    <add key="ConnectionString" value="server=localhost;user=;port=;" />
    <add key="MS" value="MSr" />
    <add key="MassagesTable" value="Massages" />
  </appSettings>

I want to add an inner elements under "MassagesTable" with names columnOne and ColumnTwo. How I can do it , and them to read it from the code .

Currently I do it like ConfigurationManager.AppSettings["ConnectionString"];

Thanks for help.

Alex Aza
  • 76,499
  • 26
  • 155
  • 134
Night Walker
  • 20,638
  • 52
  • 151
  • 228
  • 1
    Also note that connectionstrings have their own section in `web.config` since .Net 2.0. Have a look here: http://msdn.microsoft.com/en-us/library/bf7sd233.aspx – Bazzz Jun 25 '11 at 07:06

1 Answers1

1

You can find an example here: Custom type application settings in ASP.NET

Basically you can add any custom object as a setting, as long as you used 'typed settings' and the classes XML-serializable or have type converters. You should use applicaitonSettings section instead of appSettings for this.

Community
  • 1
  • 1
Alex Aza
  • 76,499
  • 26
  • 155
  • 134