Are there any standards for switching out connection strings for different environments in C# web apps? I'm currently evaluating which ways are the most secure including where to store them. I've seen people simply add them to the web config and switch them in code with if statements checking which environment they are on, but this seems cumbersome. Any ideas? Thanks.
3 Answers
How bout Web config transformation?
It's available with VS2010
3 Comments
i find the answer to questions like this is that if you're having to manually do anything to your application's configuration you're doing it wrong. check out this scott hanselmen blog/video on web deploy. the best 45 minutes you'll spend this week.
1 Comment
This should be part of your automated build process. I am a developer for BuildMaster, and it will handle this configuration file dilemma quite easily. Basically, you can create one "instance" of a configuration file in the tool for each environment you have, and you can even restrict access to any instance so for example, no developers could see production's configuration. When you're configuring the deployment plans to a certain environment, you can specify the instance you want to deploy, or you can deploy them manually from the tool at any time.
If you want more information, take a look at our configuration files feature section.