我如何与web.Release.config URL重写工作的变换? [英] How do I make URL rewrite work with web.Release.config transform?

查看:120
本文介绍了我如何与web.Release.config URL重写工作的变换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我指定所有流量转移到HTTPS一个web.config重写规则。该规则的作品,但我不希望在我调试所需的SSL。我有一堆web.release.config转换被已经做了发布工作,所以我决定把一个重写规则在里面。的问题是,重写规则不被变换等的设置的其余部分。这里是web.config中设置:

I have a web.config rewrite rule specified to move all traffic to https. The rule works, but I don't want SSL required while I am debugging. I have a bunch of web.release.config transformations being done already that work on publish so I decided to put a rewrite rule in there. The problem is that the rewrite rule isn't being transformed like the rest of the settings. Here is the web.config setup:

<system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true"/>

    <rewrite></rewrite>
</system.webServer>

和这里正在做转型:

  <system.webServer>
<rewrite>
  <rules>
    <rule name="Redirect HTTP to HTTPS" stopProcessing="true">
      <match url="(.*)"/>
      <conditions>
        <add input="{HTTPS}" pattern="^OFF$"/>
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther"/>
    </rule>
  </rules>
</rewrite></system.webServer>

如果我只是重写规则复制到web.config中它工作正常。有没有人在那里有何web.Release.config转换并不只这部分工作的任何想法?

If I just copy the rewrite rule to the web.config it works fine. Does anyone out there have any ideas why web.Release.config transforms aren't working for only this section?

推荐答案

如果你把需要转换的元素适当 XDT 属性转换才会发生。尝试添加 XDT:转换属性为您发布的配置:

Transformation will only happen if you put proper xdt attributes on the elements that need to be transformed. Try adding an xdt:Transform attribute to your release config:

<system.webServer xdt:Transform="Replace">
    <!-- the rest of your element goes here -->
</system.webServer>

这将告诉转换引擎需要更换从的Web.config 整个 system.webServer 元素从 Web.Release.config 之一。

That will tell the transformation engine that the entire system.webServer element from Web.config needs to be replaced with the one from Web.Release.config.

转换引擎将自动忽略不具有 XDT 的任何元素属性。

The transformation engine will silently ignore any elements that do not have xdt attributes.

强制性链接 MSDN

这篇关于我如何与web.Release.config URL重写工作的变换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆