在 http:// 到 https:// 重定向期间重定向循环
我试图强制页面在 SSL 下运行,因此我在 page_load 上实现了以下内容:
if (!Request.IsLocal && !Request.IsSecureConnection)
{
Response.Redirect(Helper.GetInstance().SSLBaseURL() + ScriptName());
}
由于某种原因,这最终陷入循环。 今天早些时候,我检查了 Request.Uri.Scheme,它解析为“http”,尽管我明显连接到 https://www.domain.com/pagename.aspx。
您能想到为什么此页面无法正确检测到我们在 https 下运行的任何原因吗?
I am trying to force a page to be run under SSL, so I have implemented the following on page_load:
if (!Request.IsLocal && !Request.IsSecureConnection)
{
Response.Redirect(Helper.GetInstance().SSLBaseURL() + ScriptName());
}
For some reason this is ending up in a loop. Earlier today, I checked Request.Uri.Scheme, and it was resolving as "http", though I was clearly connected to https://www.domain.com/pagename.aspx.
Any reason you can think of why this page isn't correctly detecting that we're running under https?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会在网络服务器端处理这个问题。 如果您运行的是 IIS,情况就没那么简单,但您可以启用强制 SSL 选项,并为 403;4(我认为这是 SSL 所需的错误)实现自定义错误页面,重定向到 https。
I would handle this on the webserver side. If you're running IIS, it's not as simple, but you could enable the force SSL option and implement a custom error page for your 403;4 (I think that's the SSL required error) that redirects to https.