Search code examples
c#.netenvironment-variablesweb-config

Is there a way to set a Web References URL in an Environment Variable instead of in the web.config?


I'd like to pull the Web References URL configuration out of my web.config so that we don't have to maintain separate config files for each environment.

The path we decided on was to store variables as Environment variables. Is there a way for me to point my Web Reference to use the URL variable that I set up instead of the web.config? I haven't been able to find anything yet...

Note, This is what I'm talking about when I say "Environment Variables":

enter image description here


Solution

  • Why not? Its just a string. Use Environment.GetEnvironmentVariable. You should set it at the system level so that its easier to configure. Make sure you provide a fall back and appropriate error handling.