【问题标题】:Too many redirects MVC project太多重定向 MVC 项目
【发布时间】:2018-10-10 19:48:33
【问题描述】:

我有一个使用 Azure Active Directory 作为 SSO 的 .net 项目。经过测试,本地一切正常。

我将项目部署在具有 2 个负载均衡器的环境中,但我开始收到错误消息:

此页面无法正常工作 xxx.com 重定向您的次数过多。 尝试清除您的 cookie。 ERR_TOO_MANY_REDIRECTS

  protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);

        AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;

        //This is the line causing the issue
        GlobalFilters.Filters.Add(new RequireHttpsAttribute()); 


    }

在 chrome 中网站加载正常,但在 IE 中,为 OpenId 创建的 cookie 太多。

我也试过这个:

      protected void Application_BeginRequest()
      {
         if (!Context.Request.IsSecureConnection)

         Response.Redirect(Context.Request.Url.ToString().Replace("http:", 
        "https:"));
      }

我什至尝试过 KentorOwin:

         app.SetDefaultSignInAsAuthenticationType
         (CookieAuthenticationDefaults.AuthenticationType);

        app.UseKentorOwinCookieSaver();

        app.UseCookieAuthentication(new CookieAuthenticationOptions());   

但似乎没有任何效果。

有什么帮助吗? 谢谢。

【问题讨论】:

    标签: owin


    【解决方案1】:

    我知道我正在使用的环境是接受 HTTPS 作为请求,然后由于有负载平衡器而被重定向到 HTTP。

    可能是问题的原因。

    【讨论】:

      猜你喜欢
      • 2018-08-05
      • 2016-02-28
      • 1970-01-01
      • 1970-01-01
      • 2021-03-25
      • 1970-01-01
      • 2015-06-13
      • 2019-09-11
      • 1970-01-01
      相关资源
      最近更新 更多