【发布时间】:2011-05-29 05:39:03
【问题描述】:
我正在尝试在 .NET 4 上运行的 ASP.NET MVC 2 项目中使用 Web.config 转换。但是,我遇到了一个问题:
// Root Web.config
<add name="MyDB" connectionString="default...default" />
// Root Web.Debug.config
<add name="MyDB" connectionString="debug...debug" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
// Root Web.Release.config
<add name="MyDB" connectionString="release... release" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
我不断收到此错误:
警告源文档中没有元素匹配 '/configuration/add[@name='MyDB']' C:\filePath\Web.Release.config
我将其缩小到 Views 文件夹中的 Web.Config 文件。如果我给它一个connectionString,例如根Web.config 文件中的那个,那么一切都很好,但这意味着我必须维护两个Web.config 文件。有什么解决办法吗?我做错了吗?
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-2 web-config transformation