G
Guest
Is there a way in ASP.NET 2.0 to have different connection strings settings
in a web.config files that are dynamically used based upon the server that
the web application is running on?
For example, you have have two test web servers (TEST1 and TEST2) and a
production web server (PROD1). Each of these connection to a different
database for general data access and for membership/role providers.
<connectionStrings>
<add name="Test1DB" connectionString="Data Source=Test1DBServer;Initial
Catalog=MyApp;User Id=User;Password=password;" />
<add name="Test2DB" connectionString="Data Source=Test2DBServer;Initial
Catalog=MyApp;User Id=User;Password=password;" />
<add name="Prod1DB" connectionString="Data Source=Prod1DBServer;Initial
Catalog=MyApp;User Id=User;Password=password;" />
</connectionStrings>
....
<providers>
<add name="CustomizedMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="Prod1DB"
applicationName="MyApp"
minRequiredPasswordLength="5"
minRequiredNonalphanumericCharacters="0" />
</providers>
If this application is running on my production server (PROD1) all is well
as the provider is set to use the Prod1DB connection string. However, if the
application is running on my TEST1 web server, how do I programmatically
change the connectionStringName setting to the Test1DB connection string?
Thanks,
in a web.config files that are dynamically used based upon the server that
the web application is running on?
For example, you have have two test web servers (TEST1 and TEST2) and a
production web server (PROD1). Each of these connection to a different
database for general data access and for membership/role providers.
<connectionStrings>
<add name="Test1DB" connectionString="Data Source=Test1DBServer;Initial
Catalog=MyApp;User Id=User;Password=password;" />
<add name="Test2DB" connectionString="Data Source=Test2DBServer;Initial
Catalog=MyApp;User Id=User;Password=password;" />
<add name="Prod1DB" connectionString="Data Source=Prod1DBServer;Initial
Catalog=MyApp;User Id=User;Password=password;" />
</connectionStrings>
....
<providers>
<add name="CustomizedMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="Prod1DB"
applicationName="MyApp"
minRequiredPasswordLength="5"
minRequiredNonalphanumericCharacters="0" />
</providers>
If this application is running on my production server (PROD1) all is well
as the provider is set to use the Prod1DB connection string. However, if the
application is running on my TEST1 web server, how do I programmatically
change the connectionStringName setting to the Test1DB connection string?
Thanks,