针对xslt–通过configSource链接到web.config的部分配置文件可以在Web项目中转换吗?这个问题,本篇文章进行了详细的解答,同时本文还将给你拓展.net–web.config是否覆
针对xslt – 通过configSource链接到web.config的部分配置文件可以在Web项目中转换吗?这个问题,本篇文章进行了详细的解答,同时本文还将给你拓展.net – web.config是否覆盖任何app.configs?、asp.net – Web.Debug.config没有将连接字符串转换为MVC 5项目中的Web.config、asp.net – 单独配置文件为web.config的部分、asp.net – 可以创建.config文件并将其包含到web.config中吗?等相关知识,希望可以帮助到你。
本文目录一览:- xslt – 通过configSource链接到web.config的部分配置文件可以在Web项目中转换吗?
- .net – web.config是否覆盖任何app.configs?
- asp.net – Web.Debug.config没有将连接字符串转换为MVC 5项目中的Web.config
- asp.net – 单独配置文件为web.config的部分
- asp.net – 可以创建.config文件并将其包含到web.config中吗?
xslt – 通过configSource链接到web.config的部分配置文件可以在Web项目中转换吗?
例如,我们在web.config中包含对部分配置AppSettings.config和Connectionsstring.config的引用,如下所示:
</system.web> <connectionStrings configSource ="Connectionsstring.config"></connectionStrings> <appSettings configSource ="AppSettings.config"></appSettings> </configuration>
然后在AppSettings.config中我们只有AppSettings部分,如下所示:
<appSettings> <add key="LostPasswordBCC" value="knock@timmons.com" /> </appSettings>
最后在转换文件AppSettings.Debug.config中我们有一些补充:
<?xml version="1.0" encoding="utf-8" ?> <!-- For more information on using transformations see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. --> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <appSettings > <add key="Release" value="Something" xdt:Transform="Insert" /> </appSettings> </configuration>
显然上面只是一个测试,看看转换发生了,但我们发现的是,在尝试预览转换时,我们得到的所有内容都是错误“处理转换时出错”.发布尝试也失败了.
如果我们使配置文件完全形成xml而不是从web.config引用,那么转换似乎工作正常 – 但是希望在多个项目中共享这些文件.
有没有人知道是否有一个解决方法,我们既可以从web.config引用部分配置,也可以转换这些部分文件?我们正在处理遗留代码,其中包含多个尝试合并的Web项目中的大量配置文件,因此需要从Web配置链接到单独的共享文件.
解决方法
这使我们能够继续解决我们需要解决的实际问题,这个问题是想要使用Visual Studio 2012的发布配置文件转换除web.config之外的项目配置.这最初不起作用,但Sayed再次帮助我们,并提供了一个新的SlowCheetah副本,允许这个工作.
以下是使用修复程序:https://github.com/sayedihashimi/slow-cheetah/issues/46的新版SlowCheetah的链接
非常感谢您的所有时间和耐心Sayed.
.net – web.config是否覆盖任何app.configs?
解决方法
即使您将库的.config文件放在同一文件夹中,应用程序也不会从中获取值.
如果您希望使用其中一些值,可以将它们合并到web.config中.
asp.net – Web.Debug.config没有将连接字符串转换为MVC 5项目中的Web.config
阅读几篇文章,我真的没有看到我真正需要做的是为了让它从Web.Debug.config获取我的值并替换当前的Web.config.
我一直在寻找另一个工作项目,它做到了这一点并且工作正常,但我经历了很多属性和设置,我没有看到有什么不同.
我可以右键单击Web.Debug.config和Preview,它会告诉我它将用“10.10.10.10”替换“test”,所以它对我来说似乎很好(就像它应该工作但运行项目它不会改变值)
例
项目:
调试/任何cpu,运行谷歌浏览器,问题是数据源没有被更改
Web.Debug.config
<connectionStrings> <add name="Envy" connectionString="Data Source=10.10.10.10\MSsqlSERVER2014;Initial Catalog=myDB;user id=myLoginID;password=password" providerName="System.Data.sqlClient" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> <add name="EnvyIdentity" connectionString="Data Source=10.10.10.10\MSsqlSERVER2014;Initial Catalog=myDB;user id=myLoginID;password=password" providerName="System.Data.sqlClient" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> <add name="DNNSmartstore" connectionString="Data Source=10.10.10.10\MSsqlSERVER2014;Initial Catalog=myDB;user id=myLoginID;password=password" providerName="System.Data.sqlClient" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> <add name="DNNPos" connectionString="Data Source=10.10.10.10\MSsqlSERVER2014;Initial Catalog=DevFood_POS;user id=myLoginID;password=password" providerName="System.Data.sqlClient" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> </connectionStrings>
Web.config文件
<connectionStrings> <add name="Envy" connectionString="Data Source=test\MSsqlSERVER2014;Initial Catalog=myDB;user id=myLoginID;password=password" providerName="System.Data.sqlClient"/> <add name="EnvyIdentity" connectionString="Data Source=10.10.10.10\MSsqlSERVER2014;Initial Catalog=myDB;user id=myLoginID;password=password" providerName="System.Data.sqlClient"/> <add name="DNNSmartstore" connectionString="Data Source=10.10.10.10\MSsqlSERVER2014;Initial Catalog=myDB;user id=myLoginID;password=password" providerName="System.Data.sqlClient"/> <add name="DNNPos" connectionString="Data Source=10.10.10.10\MSsqlSERVER2014;Initial Catalog=DevFood_POS;user id=myLoginID;password=password" providerName="System.Data.sqlClient"/> </connectionStrings>
解决方法
要在构建时实现这一点,您可能需要对项目文件进行一些手动编辑.看看前面的例子:https://gist.github.com/EdCharbeneau/9135216
asp.net – 单独配置文件为web.config的部分
解决方法
07000
<system.webServer> <rewrite> <rewriteMaps configSource="rewritemaps.config" /> <rules configSource="rewriteRules.config" /> </rewrite> </system.webServer>
此外,您可以将不少配置部分移动到自己的文件中:
<appSettings configSource="appSettings.config" />
07001
<connectionStrings configSource="connectionStrings.config"/>
07002
<pages configSource="pages.config"/>
07003
有关更多信息,请参阅此页面,这将帮助您确定配置部分是否可以从外部存储:
07004
asp.net – 可以创建.config文件并将其包含到web.config中吗?
我该怎么办?
UPD。
如果要分离配置文件,例如,将appSettings移动到另一个必须执行下一步的文件:在web.config中
<appSettings configSource="myAppSettings.config" />
在myAppSettings.config中:
<appSettings> <add key="ClientValidationEnabled" value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true" /> </appSettings>
解决方法
configSource
属性由主.config文件引用。
有关详细信息,请参阅this博客。
关于xslt – 通过configSource链接到web.config的部分配置文件可以在Web项目中转换吗?的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于.net – web.config是否覆盖任何app.configs?、asp.net – Web.Debug.config没有将连接字符串转换为MVC 5项目中的Web.config、asp.net – 单独配置文件为web.config的部分、asp.net – 可以创建.config文件并将其包含到web.config中吗?的相关信息,请在本站寻找。
本文标签: