重定向后重定向太多重定向代码强制https

时间:2017-09-22 09:44:05

标签: c# asp.net-mvc https

我在asp.net mvc中有一个网站应用程序。 要对用户进行身份验证,请使用Microsoft SSO authenticate

iis配置有ssl证书。

我有以下问题: 在Chrome中,当我输入此网址时:https://mydomain/myapplication

自动重定向到:https://loginmicrosoft.....

回到我的网站上,我的网址没有安全地传入http。

如果我刷新此网址,我会回复https。

现在,我在global.asax中测试了这段代码:

protected void Application_BeginRequest(Object sender, EventArgs e)
{
    if (HttpContext.Current.Request.IsSecureConnection.Equals(false) && HttpContext.Current.Request.IsLocal.Equals(false))
    {
        Response.Redirect("https://" + Request.ServerVariables["HTTP_HOST"] + HttpContext.Current.Request.RawUrl);
    }
}

有了这个,我有太多的重定向。

你有什么解决方案吗?

由于

0 个答案:

没有答案