When is the <appSettings> section used over the custom configuration section?

When creating my application or library configuration, I usually prefer to use the custom configuration section in the <appSettings> section for the following reasons.

  • Serialization of the structure into a user configuration object; each configuration value has a corresponding type
  • Configuration values ​​can be checked to match ranges of types and values ​​with attributes

Given this, when do I want to use the input / subtraction mechanism of the <add/> type of the <add/> section of the <appSettings> ? As far as I remember, the application level configuration in this section can override the existing machine level configuration from machine.config. Is this the only case, or are there other reasons?

+4
source share
2 answers

This is easier for fast and dirty applications.

For the same reason, ASP.NET has things like the magic method "Page_Load" - there is no explicit wiring, you probably don't use it in a corporate application; It is just for RAD.

+5
source

The appSettings tag has a file attribute that allows you to redirect the entire appSettings section to an external file. For example, you may have different instances of appSettings for different environments: dev.config, qa.config, etc. I'm not sure if you can do this with other configuration sections.

Example:

 <appSettings file="qa.config"/> 
+1
source

Source: https://habr.com/ru/post/1316611/


All Articles