Search code examples
.netconfigurationappsettingsconfigurationmanagercustom-configuration

When is using the <appSettings> section preferable to a custom configuration section?


When creating my application's or library's configuration, I generally prefer using a custom configuration section over the <appSettings> section for the following reasons.

  • Framework serialization to a user-defined configuration object; each config value has an appropriate type
  • Configuration values may be validated against type and value ranges with attributes

Given this, when would I want to use the loose-typed <add/> key/value mechanism of the <appSettings> section? As I recall, application-level configuration in this section can override existing machine-level configuration from machine.config. Is this the only case, or are there other reasons?


Solution

  • It's easier for quick-and-dirty applications.

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