如何在连接字符串上使用Web.Config变换?
在我当前的项目中,我有一些对本地开发机器有效的连接字符串:
<add name="ApplicationServices" connectionString="Data Source=localhost;Initial Catalog=MyDB;Integrated Security=SSPI" ....
我如何使用Web.Config转换将此表达式转换为对我们的生产服务器有效的表达式? 生产服务器看起来像:
<add name="ApplicationServices" connectionString="Data Source=IPAddress,Port;Initial Catalog=SomeOtherDB;User ID=TopSecretUsername;Password=SecurePassword" ....
语法对我来说并不明显,而且我完全没有在它上面浏览页面 。
这对我有用,但我也发现它有时会有点松懈。 您将需要创建另一个名为Web.Config.Release的文件,并使用以下内容填充它:
您不需要创建新文件,它应该在解决方案资源管理器中,展开Web.config,然后打开Web.Release.config。
Scott Allan在这里有一个很好的video(在配置和部署>配置转换下)。