在http://到https:// redirect期间重定向循环 [英] Redirect loop during http:// to https:// redirect

查看:186
本文介绍了在http://到https:// redirect期间重定向循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图强制页面在SSL下运行,所以我在page_load上实现了以下内容:

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());
        }

由于某种原因,这将以循环结束。今天早些时候,我检查了Request.Uri.Scheme,它正在解析为http,虽然我明显连接到 https://www.domain.com/pagename.aspx

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.

您可以想到为什么此页面无法正确检测到我们在https下运行?

Any reason you can think of why this page isn't correctly detecting that we're running under https?

推荐答案

我会在网络服务器端处理这个问题。如果你正在运行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.

这篇关于在http://到https:// redirect期间重定向循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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