如何为ASMX服务实施HTTPS [英] How to Enforce HTTPS For ASMX Service
问题描述
我在IIS7上运行了许多现有的ASMX Web服务,并希望对其进行更改,以便所有请求和响应都必须通过HTTPS进行。
I have a number of existing ASMX web services running on IIS7, and want to change them so that all requests and responses must be made over HTTPS.
该站点还运行其他页面,如PHP和Classic ASP,因此我不能只更改站点根目录以提供HTTPS页面。
The site is also running other pages like PHP and Classic ASP, so I can't just change the site root to serve HTTPS pages.
如何根据ASMX服务设置此值(应用程序),以便有人访问 http://www.mydomain.com/MyService/ServiceName.asmx 它会将它们重定向到 https://www.mydomain.com/MyService/ServiceName。 asmx 或返回404错误?
How can I set this per ASMX serivce (application), so that if somebody visits http://www.mydomain.com/MyService/ServiceName.asmx it either redirects them to https://www.mydomain.com/MyService/ServiceName.asmx or returns a 404 error ?
思考和最佳方法?
推荐答案
您是否尝试过URL重写?
Have you tried with URL rewrite?
<rewrite>
<rules>
<rule name="Force HTTPS" stopProcessing="true">
<match url="(.*)/ServiceName.asmx" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
这篇关于如何为ASMX服务实施HTTPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!