Mat*_*amp 45 asp.net asp.net-mvc web-config-transform
我有一个web.config重写规则指定将所有流量移动到https.该规则有效,但我在调试时不需要SSL.我已经完成了一堆web.release.config转换工作,因此我决定在那里放一个重写规则.问题是重写规则没有像其他设置那样进行转换.这是web.config设置:
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
<rewrite></rewrite>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
以下是正在进行的转型:
<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>
Run Code Online (Sandbox Code Playgroud)
如果我只是将重写规则复制到web.config它可以正常工作.有没有人有任何想法为什么web.Release.config转换不仅适用于此部分?
Lob*_*ity 44
只有xdt
在需要转换的元素上放置适当的属性时才会发生转换.尝试xdt:Transform
在发布配置中添加属性:
<system.webServer xdt:Transform="Replace">
<!-- the rest of your element goes here -->
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
这将告诉转换引擎需要将整个system.webServer
元素Web.config
替换为Web.Release.config
.
转换引擎将默默地忽略任何没有xdt
属性的元素.
与MSDN的强制性链接.
cit*_*nas 33
另一种方法是设置一个重写条件,如果你在localhost上则否定:
<conditions>
<add input="{HTTP_HOST}" pattern="localhost" negate="true"/>
</conditions>
Run Code Online (Sandbox Code Playgroud)
<system.webServer>
<rewrite>
<rules xdt:Transform="Replace">
<clear />
<rule name="Redirect HTTP to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="localhost(:\d+)?" negate="true" />
<add input="{HTTP_HOST}" pattern="127\.0\.0\.1(:\d+)?" negate="true" />
<add input="{HTTPS}" pattern="OFF" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
14042 次 |
最近记录: |