0

In my asp.net website i have multiple connectionstring in web.config. I need to pick a connection string when i publish on my local server for test, and the other one when I have to publish on "real server" when i need to release.

<!-- LOCAL SQLEXPRESS -->
<add name="LocalConnectionString" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=TimeLive;Persist Security Info=True;User ID=*********;Password="*********" providerName="System.Data.SqlClient"/>
<!-- IPR-GEST SQLEXPRESS  -->
<add name="ServerReleaseConnectionString" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=TimeLive;Persist Security Info=True;User ID=*********;Password=*********" providerName="System.Data.SqlClient"/>

Since the two connectionString differs from user login, I thought it's possible changing server authentication switching to "Windows Authentication", but sounds like less secure. Am I wrong?

How can I choose the right connectionString depending on I publish on local or release server?

Also, the solution contains a dll project with a .dbml file. Same problem: two different connectionString, one for each server. Is there a simple way to choose the right one?

insilenzio
  • 918
  • 1
  • 9
  • 23
  • Windows authentication is even more secure than SQL logins, from the point of view that the passwords are not stored anywhere. – Oscar Jun 12 '14 at 15:43

1 Answers1

1

Depending which version of Visual Studio you have, it has Web.config File Transformations, it allows you to have a configuration template for development and another for production.

http://www.asp.net/mvc/tutorials/deployment/visual-studio-web-deployment/web-config-transformations

Oscar
  • 13,594
  • 8
  • 47
  • 75