asp.net – 如何在发布项目时交换连接字符串?
发布时间:2020-12-16 06:32:55 所属栏目:asp.Net 来源:网络整理
导读:我可以看到Web.config文件包含两个文件: -web.Debug.config-web.Release.config 在这个配置文件中有以下注释: In the example below,the “SetAttributes” transform will change the value of “connectionString” to use “ReleaseSQLServer” only wh
我可以看到Web.config文件包含两个文件:
-web.Debug.config -web.Release.config 在这个配置文件中有以下注释:
<connectionStrings> <add name="MyDB" connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> </connectionStrings> 什么是“匹配”定位器? 解决方法
我们正在使用xdt:Transform =“Replace”,它基本上替换了我们的开发DB的连接字符串,它完美地工作.见下文:
开发连接字符串(在您的情况下是web.Debug.config): <connectionStrings> <add name="MyDB" connectionString="Data Source=DebugSQLServer;Initial Catalog=MyDebugDB;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> 生产连接字符串(在您的情况下是web.Release.config): <connectionStrings xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <add name="MyDB" connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" xdt:Transform="Replace" xdt:Locator="Match(name)" /> </connectionStrings> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 在数据实体框架中显示名称
- asp.net – 引用依赖于ConfigurationManager的.net core 2中
- asp.net-core – ASP.NET Core中的状态码406(不可接受)
- asp.net – 你能以编程方式设置MachineKey吗?
- asp.net – 使用Visual Studio 2012发布到azure时,我可以使
- ASP.NET:如何在没有任何子域的情况下获取域名?
- 在ASP.NET站点中将.Net 2.0与.Net 4.0混合使用
- asp.net-core – IApplicationBuilder不包含UseStaticFiles
- asp.net – 为VS2010和TFS中的团队管理web.config
- asp.net – 将数组传递给客户端进行显示
推荐文章
站长推荐
- asp.net – 在同一个项目的MVC和Web API中使用In
- asp.net-mvc – ASP.Net MVC 2验证是否需要更多的
- asp.net – 在请求之间检索和持久化状态
- 在大型asp.net C#Web应用程序中修复SQL注入表单
- asp.net-mvc – ASP.NET MVC下拉列表
- asp.net-mvc-3 – 为什么asp.net mvc模型绑定器生
- asp.net – 在运行时更改SqlDataSource.SelectCo
- 具有虚拟目录的ASP.net母版页中的基本URL
- ASP.NET超链接asp:HyperLink与A href
- asp.net-mvc – 在视图中转义JavaScript字符串文
热点阅读