ADFS v2.0 Error : MSIS7042: The same client browser session has made '6' requests in the last '1' seconds

亡梦爱人 提交于 2019-12-01 04:38:01

I had the same issue with ADFS 1.0 And to resolve it, I made sure that the URL had a trailing forward slash "/" that would always work in FireFox as well as IE

eg : https://somedomain.com/Application_2/

Turns out that the host name of the relying party had an underscore in it (khoffman_2). Apparently, the underscore is an illegal DNS character and ONLY IE will reject the information with the underscore in it.

I renamed my machine from khoffman_2 to khoffman2 and the ADFS v2/MVC relying party combination works flawlessly on Firefox, Safari, AND IE.

While this isn't your problem, we have had identical problems to what you described. Our solution was to:

  1. Enabled Basic Authentication in IIS (this solved nothing but was required for the next 2 steps)
  2. Disable Windows Authentication in IIS (this solved the problem for some IE browsers but not all)
  3. Disable Anonymous Access in IIS (this solved the problem for the rest of the IE browsers)
Hlefreyr

Jaxidian's answer is close.

In my case I only had to:

  • Windows Authentication -> Disabled

  • Anonymous Auth -> Enabled

  • ASP.NET Impersonation -> Disabled

  • Forms Auth -> Disabled

  • Windows Auth -> Disabled

WWC

This loop can occur when a user is not authorized to access a page.

We had a custom authorization attribute on our MVC controller that checks to see if the user was in a role based on the claims provided if the setting for UseADFS was true in the config files. I thought this setting was set to true and was confounded that I kept getting the adfs loop when accessing the page because I was in the groups that were authorized to access the page.

The key to troubleshooting was to make a web page that displayed my adfs claims without necessarily requiring authentication.

@if (User.Identity.IsAuthenticated)
{
    <div>UserName: @User.Identity.Name;</div>

    var claimsIdentity = User.Identity as System.Security.Claims.ClaimsIdentity;
    <table>
        @foreach (var claim in claimsIdentity.Claims)
        {
        <tr><td>@claim.Type</td><td>@claim.Value</td></tr>
        }
    </table>


}

I noticed that I was getting logged into ADFS, and my claims were getting set, so ADFS was working. The actual issue was my config file had UserADFS="true" instead of UseADFS="true" which basically caused my custom authorization code to return false on authorization. Therefore, the page kept forwarding me back to adfs to authenticate again.

Anyways, if a user does not have the correct claims to access the page, then this adfs login loop can occur, as well.

Also, if you wrote a custom authorize attribute be sure to check out the following link which describes how to prevent the loop.

Redirect loop with .Net MVC Authorize attribute with ADFS Claims

Custom HandleUnauthorizedRequest handler code for AuthorizeAttribute from that link:

 protected override void HandleUnauthorizedRequest System.Web.Mvc.AuthorizationContext filterContext)
    {
        if (filterContext.HttpContext.Request.IsAuthenticated)
        {
            //One Strategy:
            //filterContext.Result = new System.Web.Mvc.HttpStatusCodeResult((int)System.Net.HttpStatusCode.Forbidden);

            //Another Strategy:
            filterContext.Result = new RedirectToRouteResult(
                new RouteValueDictionary(
                    new
                    {
                        controller = "u",
                        action = "LoginStatus",
                        errorMessage = "Error occurred during authorization or you do not have sufficient priviliges to view this page."
                    })
                );
        }
        else
        {
            base.HandleUnauthorizedRequest(filterContext);
        }
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!