redirect - 如何编写 iis 配置规则以停止 .asmx 的重定向
问题描述
我的 Web 配置中有此部分,用于将 http 请求重定向到 https,不包括 .asmx 引用
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{URL}" pattern="^.aspx" ignoreCase="true" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
这可以重定向 http 请求,但 Web 服务不起作用 - 我明白了
<head><title>Document Moved</title></head>
<body><h1>Object Moved</h1>This document may be found <a
HREF="https://v3.myurl.net/WSEntrant.asmx">here</a></body>
产生的错误是
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at PCS_Spe
cification.wsEntrant.WSEntrant.refresh
解决方案
<add input="{URL}" pattern="^.aspx" ignoreCase="true" negate="true" />
您想停止 的重定向.asmx
,但在您的重写规则中,您的参数是.aspx
,因此您需要将参数更改为.asmx
。
或者您也可以尝试以下重写规则:
<rule name="RewriteAllButasmx" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{URL}" negate="true" pattern="\.asmx$" />
</conditions>
<action type="Rewrite" url="https://{HTTP_HOST}/{R:1}" />
推荐阅读
- python - a[:,:,0] 和 a[:][:][0] 之间的差异
- c# - 将鼠标指针移到原始图像上时如何找到它所属的文件?
- amazon-web-services - 如何在 AWS Athena 中用 0 填充空值
- git - 拉分支后Git子模块更新
- cockroachdb - CockroachDB:为什么删除速度会随着时间的推移而变慢?
- linux - cURL 命令适用于 linux 但不适用于 windows
- java - 从 ip Java 获取主机名
- sparql - SPARQLRule 未构造
- wcf - 使用 .Net Core 5 在 BackgroundService 中托管 SOAP 服务
- python - 在 Seaborn 中格式化绘图