2

我正在使用 VS2012 并且在发布 mvc4 网站时遇到了一些麻烦。

我的发布设置均未应用。

在我的配置中,我有这个

网络配置

  <compilation debug="true" targetFramework="4.0" />
  <authentication mode="Forms">
    <forms loginUrl="~/Account/Login" timeout="2880" name="***" enableCrossAppRedirects="true" />

发布

 <?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">
<appSettings>
    <add key="ApiBaseUrl" value="https://api.mydomain.com/api/"  xdt:Transform="Replace" xdt:Locator="Match(key)" />
</appSettings>
<!--
In the example below, the "SetAttributes" transform will change the value of 
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator 
finds an atrribute "name" that has a value of "MyDB".
    <connectionStrings>
  <add name="MyDB" 
    connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" 
    xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
      -->
<system.web>
  <compilation xdt:Transform="RemoveAttributes(debug)" />
  <authentication mode="Forms" xdt:Transform="Replace">
      <forms loginUrl="~/Account/Login" timeout="2880" name="***" enableCrossAppRedirects="true" domain="www.mydomain.com"/>
  </authentication>
   <!--
  In the example below, the "Replace" transform will replace the entire 
  <customErrors> section of your Web.config file.
  Note that because there is only one customErrors section under the 
  <system.web> node, there is no need to use the "xdt:Locator" attribute.

  <customErrors defaultRedirect="GenericError.htm"
    mode="RemoteOnly" xdt:Transform="Replace">
    <error statusCode="500" redirect="InternalError.htm"/>
  </customErrors>
-->
</system.web>
<system.net>
<mailSettings>
  <smtp xdt:Transform="Replace">
    <network host="localhost"/>
  </smtp>
</mailSettings>
 </system.net>
 <dotless xdt:Transform="Replace" minifyCss="true" cache="true" web="false"  />
 </configuration>

我在设置为发布时发布。

谁能看到我做错了什么?

4

2 回答 2

0

如果您的 web.config 包含位置标签,您需要确保在发布配置中也包含这些标签。

于 2012-06-27T01:23:42.460 回答
0

在 Web 发布向导中检查您的发布配置文件。在 VS2010 中,web.config 转换是根据发布时选择的构建配置应用的,但是对于新的 Web 发布向导,我相信它存储在发布配置文件中。我相信这是他们包含在 VS2012 中的那个

于 2012-06-27T00:19:06.613 回答