AppSettings - External Config File

We've been using this for several months to distinguish between Dev / QA / Prod settings - it's worked very well. This makes it easy to keep config files in source control - there's one folder (config) with dev.config, qa.config, production.config, and any others as needed. The folder is maintained in source control so it's versioned, labeled, etc. Web.config is different from server to server (refers to a different config file depending on environment), but doesn't contain any settings.

One slight difference with this approach is that changes don't go into effect immediately. The ASP.NET process monitors web.config for changes and restarts when it changes (actually, it caches web.config and changes to the file invalidate the cache), but that doesn't cascade down to referenced external config files. A simple hack to force the reload is to add / remove whitespace in the web.config file to force a refresh.

     “I recently discovered that the app/web.config file can reference an external config file to get some or all of its appsettings. .. “

      [Paul Wilson]

No Comments