Hi,
here is the way I'm doing it.
Set a machine identity in the machine.config that says if it is a
development, stage or production server (e.g. d, s or p. It might be good to
add an "l" for local also).
for the Development-server
<add key="ApplEnv-l" value="d" />
Then you can put the connection strings for all environments into the
web.config
<add key="Connection String-l" value="server=( local);......."/>
<add key="Connection String-d" value="server=D EV-Server;......"/>
<add key="Connection String-s" value="server=S TG_Server;..... "/>
<add key="Connection String-p" value="server=P RD-Server;....."/>
In your code put something like:
private static string DbConnectionStr ing
{
get
{
string strApplEnv = ConfigurationSe ttings.AppSetti ngs["ApplEnv"];
string paramSuffix = strApplEnv.ToLo wer().Substring (0,1);
return ConfigurationSe ttings.AppSetti ngs["ConnectionStri ng-" +
paramSuffix] ;
}
This way you can use the web.config for all environments.
Regards,
Uli
--
Wer nicht fragt, stirbt dumm.
If you don''t ask, you'll die as a dumba**.
"dasomervil le" wrote:
We have different settings for our development, stage and production
environments. For example, our development environment connection strings
point to development database instances, stage connection strings point to
stage database instances and so forth.
Without having to maintain separate web.config files, what are the various
approaches to having environment-specific settings?