tags:

views:

27

answers:

1

We have a few settings in our web application that can be user configured. As IIS exposes helpers for configuring "Connection Strings" and "Application Settings" we decided to take use this method of configuration.

Unfortunately this works by editing the Web.config file deployed in the web application. This means that a simple upgrade process of copying over the files from a newer web application release resets all configuration settings to the default.

Possible options:

  • When upgrading the webapp, backup the Web.config and restore it afterwards. This is not elegant and if the latest webapp defines new default-valued properties in the Web.config then this will break

  • Write some admin-only configuration pages on the site and store the values in the DB. This puts the control back in our hands, but it will take work to write this and obviously has bootstrapping problems with connection strings.

Is there a better way?

+1  A: 

When I deploy new versions of whatever web application I am work on, I never deploy the configuration file. I always make this a manual step, it ensures that no critical changes are made accidentally. You also have the option of splitting your configuration files into small configuration files, e.g., you could fragment your appSettings and connectionStrings into seperate files:

<connectionStrings configSource="_Configuration\Connections.config" />
<appSettings configSource="_Configuration\Settings.config" />

Just manage your deployment with these files in mind.

Matthew Abbott