2

I have web application and and DB connection settings are stored in web.config The problem is that this application is deployed to multiple servers and connection string may vary. So I would like to have the same web.config on all server and actual configuration settings be externalized, for example to XXX.properties - this is pretty similar to java world - config file has place holders and values are read from other files

Again: all server has the same web.config files and unique XXX.properties

How can i configure this?

thak you

2 Answers 2

1

For connection strings you can use the configSource attribute:

<connectionStrings configSource="connectionStrings.config"></connectionStrings>

At our applications we manage the connection string configuration file varyingly. For some projects we simply store the config file somewhere outside the main project root, so we can safely publish to it. For others with proper CI setup we use a custom build task to copy the correct configuration file depending on the build type.

If you're on Visual Studio 2010, you could also look into Web Config Tranformations.

1

Just put the location of your external config file in the web.config.

Then in your code, you can read and parse your external file to get the settings for the app.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.