为什么 Request.IsSecureConnection 在预期为 true 时返回 false [英] Why does Request.IsSecureConnection return false when true is expected

查看:40
本文介绍了为什么 Request.IsSecureConnection 在预期为 true 时返回 false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 aspx 页面,它正在检查 Request.IsSecureConnection 以确保它是真的,如果不是,它会重定向到 https://www.domain.com/page.aspx.

I have an aspx page which is checking Request.IsSecureConnection to ensure it is true, if not it does a redirect to the the secure page at https://www.domain.com/page.aspx.

服务器为域安装了 SSL 证书,浏览器显示挂锁图标.

The server has an SSL cert installed for the domain, and the browser shows the padlock icon.

相同的代码在不同的服务器上运行良好,但现在 Request.IsSecureConnection 总是返回 false.

The same code ran fine on a different server, but now Request.IsSecureConnection always returns false.

我已经创建了一个完全空的 aspx 文件,它只是打印了 Request.IsSecureConnection 的返回值,它仍然是 false,所以没有来自标准 http 请求的其他内容.

I have created a completely empty aspx file, that just prints the return value of Request.IsSecureConnection and it is still false, so there is no other content coming from a standard http request.

谁能建议可能导致这种情况的原因,或者就我如何找出导致这种情况始终返回 false 的原因提供任何提示?

Could anyone suggest what might be causing this, or give any hints on how I might find out what is causing this to always return false?

推荐答案

如果您的 Web 服务器前面有负载平衡路由器或类似设备,并带有 ssl 终止,那么从那里到您的 Web 服务器的连接将不会通过 SSL.在这种情况下,您通常必须检查特定端口上的连接或负载均衡器设置的标头.

If there's a load balancing router or similar in front of your web server with ssl termination then the connection from there to your web server won't be over SSL. In this case you usually have to check for a connection on a specific port or for headers being set by the load balancer.

这篇关于为什么 Request.IsSecureConnection 在预期为 true 时返回 false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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