开发者

Migrating web application settings as configured through IIS

开发者 https://www.devze.com 2023-01-07 15:56 出处:网络
We have a few settings in our web application that can be user configured.As IIS exposes helpers开发者_C百科 for configuring \"Connection Strings\" and \"Application Settings\" we decided to take use

We have a few settings in our web application that can be user configured. As IIS exposes helpers开发者_C百科 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消