如何将 asmx Web 服务限制为仅 SSL
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我的网站上还有一些其他内容向公众开放,所以我选择不走 IIS 路线。我确实在 asmx 服务中找到了一个简单的方法来解决这个问题:
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:
简单的。在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
在 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.