我的Web.Config转换没有发布 - 我认为错误与我得到的这些警告有关。
使用Visual Studio 2010,我正在使用我的Web.Config
/ Web.Config.Debug
个文件。
在我的.Debug
文件中,我多次列出以下警告。
No element in the source document matches '/configuration'
我认为它列出了.Debug
文件中存在的每个部分。
所以使用以下示例Web.Config.Debug文件..将列出两次。 (我猜,第一个用于<connectionStrings>..</>
,第二个用于<system.webServer>...</.>
)
<?xml version="1.0"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xdt:SupressWarnings="false">
<connectionStrings>
<add name="Foo" connectionString="Server=foo;Database=Foo;uid=foo;password=foo" providerName="System.Data.SqlClient"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
<system.webServer>
<httpProtocol>
<customHeaders>
<clear />
<add name="ETag" value="Dev_IIS" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
有人可以帮忙吗?
答案 0 :(得分:3)
我发现this blog post表明转换器在xmlns = attributes上窒息。
我改变了我的Web.config文件:
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
etc...
到此:
<configuration>
<connectionStrings>
etc...
......瞧,它有效!
答案 1 :(得分:0)
我创建了一个新的Web应用程序项目(目标.net 4.0),更改了Web.Release.config以准确包含您上面粘贴的内容。然后我去了web.config并添加了以下内容:
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
<add name="Foo" /> <------------------------added this
</connectionStrings>
然后我将配置更改为发布并发布了Web应用程序。已发布的应用程序在web.config中包含以下内容
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
<add name="Foo"
connectionString="Server=foo;Database=Foo;uid=foo;password=foo"
providerName="System.Data.SqlClient" /> <-------this got added
所以我不确定你的问题在哪里。