0

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.

1
  • You could maintain separate connection config files depending on the different environments that you will deploy to. Commented Sep 22, 2011 at 16:39

3 Answers 3

4

How bout Web config transformation?

It's available with VS2010

Sign up to request clarification or add additional context in comments.

3 Comments

+1 for teaching me something new. I was using NANT for this (and well, other stuff too, such as backing up my previous app version, pushing my app to the appropriate environment, etc) but this is useful :)
also available for "app.config"-files via the "slow cheetah" extension via NuGet/VS gallery
Link only answer. No example.
1

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

Link only answer. No example.
0

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.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.