0

Say I have two sets of web configuration, where do I put the selection code?

I want my code be able to interchangeable between two sets of configurations

John Saunders
  • 160,644
  • 26
  • 247
  • 397
9blue
  • 4,693
  • 9
  • 29
  • 43
  • Are these configuration files for separate environments or do you need separate configuration files for the same environment? Could you please care to elaborate a bit? – abhi Jan 02 '14 at 22:17
  • Do you want to switch configurations at compile time or run-time? – Bill Jan 02 '14 at 22:17
  • Preferably, I would like to have two separate configuration files for the same environment. And to make it debug friendly, I would like to switch the config at run-time if it's possible. – 9blue Jan 02 '14 at 22:23
  • Can you please provide more details? What sections do you need to change? I would guess it is related to either connectionStrings and/or AppSettings – Dalorzo Jan 02 '14 at 23:16
  • I want to maintain the old authentication method while developing the new one. So I can interchange between them. So, not only the connectionStrings and/or AppSettings are involved. – 9blue Jan 03 '14 at 20:04

1 Answers1

2

If I understand your question correctly, you want web.config files like this.

enter image description here

It basically transform Web.Config based on the selection.

If it is what you want, there are lot of questions in SO regarding that.

Web.Config Debug/Release

Web Deployment: Web.Config Transformation

Community
  • 1
  • 1
Win
  • 61,100
  • 13
  • 102
  • 181
  • I don't really want to publish, so transform is not suitable for my case. Is there a way to select web config at building? – 9blue Jan 03 '14 at 20:01