ASP.Net MVC identity infinite redirect loop

后端 未结 4 1218
说谎
说谎 2021-01-14 09:13

I have an ASP.Net MVC5 application, using the Identity \"out of the box\" template, as per ASP.Net Identity 2.0.0. I need to upgrade it to use the newer code that is in the

相关标签:
4条回答
  • 2021-01-14 09:26

    Resolved... turns out the culprit was my Unity DI configuration.

    I drilled deep to find the errors getting recursively thrown on each redirect, and it suggested the AccountController dependencies weren't being instantiated. I had a similiar issue last year Unity Container trying to resolve non registered type, throwing error , and so I looked further into the changed dependencies.

    Following the suggested answer at Register IAuthenticationManager with Unity resolved the issue.

    Thanks for the suggestions re: SSL / HTTPS / Filters, investigating these led me to the exceptions.

    0 讨论(0)
  • 2021-01-14 09:39

    Do you have SSL setup locally? Are authenticating on HTTPS then being redirected to HTTP which is killing the cookie & redirecting back to the HTTPS login page

    Have you got something in the web.config for forms authentication redirect like

      protection="All" requireSSL="true" loginUrl="~/Account/Login.aspx"
    

    Do your cookies look ok?

    0 讨论(0)
  • 2021-01-14 09:41

    I also face this same issue before and solve by adding this line in web config

    <add key="owin:AutomaticAppStartup" value="false"/>
    

    It will disable OWIN startup discovery.

    I hope it will work.

    Also check in the IIS virtual directory. Check that anonymous user is enable or not, if disabled then enable it and problem will be solved.

    0 讨论(0)
  • 2021-01-14 09:44

    I think your login action is missing [AllowAnonymous] attribute.

    0 讨论(0)
提交回复
热议问题