如何为ASMX服务实施HTTPS [英] How to Enforce HTTPS For ASMX Service

查看:192
本文介绍了如何为ASMX服务实施HTTPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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屋!

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