如何将 asmx Web 服务限制为仅 SSL

发布于 2024-08-12 04:05:28 字数 267 浏览 2 评论 0原文

我有一个 ASMX Web 服务,可以通过 SSL 连接很好地工作,但我想让这些 Web 服务在没有 SSL 的情况下无法访问。

在 Web 表单中,我将只使用以下代码:

if (!Request.IsSecureConnection) Response.Redirect ("SomeOtherPage.aspx");

我知道 WCF 承诺在各个方面都会变得更好,但使用像 WCF 这样复杂的工具来完成简单的事情才是真正的 PITA。

I've got an ASMX web service that works great through an SSL conection, but I would like to make these web services inaccessible without SSL.

In web forms, I would just use the following code:

if (!Request.IsSecureConnection) Response.Redirect ("SomeOtherPage.aspx");

I know that WCF promises to be better in every way, but it's a real PITA to get something simple done with a tool as complicated as WCF.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

伪心 2024-08-19 04:05:28

我的网站上还有一些其他内容向公众开放,所以我选择不走 IIS 路线。我确实在 asmx 服务中找到了一个简单的方法来解决这个问题:

if (!this.Context.Request.IsSecureConnection)
    return null;

I have some other stuff on my site that is open to the public, so I chose not to take the IIS route. I did find a simple way in the asmx service to take care of the problem:

if (!this.Context.Request.IsSecureConnection)
    return null;
胡渣熟男 2024-08-19 04:05:28

简单的。在IIS中创建一个只有SSL的网站并将此页面放入其中。
不允许非 SSL 连接到此网站

Easy. Make a website in IIS that is only SSL and put this page in it.
Don't allow non-SSL connections to this website

舟遥客 2024-08-19 04:05:28

在 IIS 中(我不记得确切的版本,因此它可能已移动)在网站或虚拟目录的安全选项卡下,您可以将其设置为“需要安全通道”。这将迫使它需要 https,除非我弄错了。

In IIS (I can't remember exactly which version so it may have moved) under the security tab of the website or virtual directory you can set it to 'require secure channel'. This will force it to require https unless I'm mistaken.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文