Web部署删除IIS网站自定义配置

emz*_*ero 6 asp.net iis asp.net-mvc iis-7.5 webdeploy

我正在使用Web Deploy(来自VS2013)将ASP.NET MVC站点发布到IIS 7.5.

我通过IIS管理器添加了一些URL重写规则和自定义HTTP响应头.

问题是每次部署新版本的站点时,都会删除此额外配置.

这是预期的行为还是有问题?如何在每次部署时保留这些自定义设置?

UPDATE

所以我明白我需要将这些变化放入web.config.我试图把它们放进去,Web.Release.config但它没有被添加到部署中web.config.我想我错过了一些XDT:Transform规则.

这就是我在我的内容Web.Release.config(是的,发布配置文件正在使用此版本配置).

<configuration>
    <!-- some other stuff -->
    <system.webServer>
        <rewrite>
          <rules>
            <rule name="Redirect to www" patternSyntax="Wildcard" stopProcessing="true">
              <match url="*" />
              <conditions>
                <add input="{HTTP_HOST}" pattern="mydomain.com" />
              </conditions>
              <action type="Redirect" url="http://www.mydomain.com/{R:0}" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

emz*_*ero 0

好的,所以我明白我需要使用在 web.config 中添加此自定义配置XDT:Transform

我将其添加到Web.Release.config并且它起作用了:

<system.webServer>
    <rewrite xdt:Transform="Insert">
      <rules>
        <rule name="Redirect to www" patternSyntax="Wildcard" stopProcessing="true">
          <match url="*" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="mydomain.com" />
          </conditions>
          <action type="Redirect" url="http://www.mydomain.com/{R:0}" />
        </rule>
      </rules>
    </rewrite>
 </system.webServer>
Run Code Online (Sandbox Code Playgroud)