在我的 asp.net 网站中,我在 web.config 中有多个连接字符串。当我在本地服务器上发布进行测试时,我需要选择一个连接字符串,当我需要发布时,我必须在“真实服务器”上发布另一个连接字符串。
<!-- 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"/>
由于这两个 connectionString 与用户登录不同,我认为可以将服务器身份验证切换为“Windows 身份验证”,但听起来不太安全。我错了吗?
如何根据我在本地或发布服务器上发布来选择正确的 connectionString?
此外,该解决方案包含一个带有 .dbml 文件的 dll 项目。同样的问题:两个不同的连接字符串,每个服务器一个。有没有一种简单的方法来选择合适的?