>I quite like to store variables in the web.config file. However it can make
>the web.config messy and make deployment fiddly. Is there any way of have
multiple web.config files - one with the major stuff and one with minor
stuff such as my variables which can differ from development to production.
Or alternatively is there some kind of tool to make the deployment smoother?
You can define a "configSource=........" attribute for just about
every section in your web.config, to "externalize" your config
settings to separate files:
<?xml version="1.0"?>
<configuration>
<system.web>
<pages>
...
</pages>
</system.web>
<system.serviceModel>
<bindings configSource="serviceModel_bindings.config"/>
<client configSource="serviceModel_client.config"/>
.......
</system.serviceModel>
<connectionStrings configSource="connectionStrings.config" />
........
</configuration>
Those external config files now simply contain the section that you
would normally have directly in your web.config, e.g.
connectionStrings.config:
<?xml version="1.0" encoding="utf-8" ?>
<connectionStrings>
<add name="default" connectionString="........"/>
</connectionStrings>
That alone can make your web.config a lot more readable right there -
and it's totally built in, no extra custom code needed - nada.
Hope this helps.
Marc