ASP.NET Forms Authentication - Too many redirects

27,248

Please check if you have somewhere on your page that you have redirected to same page that you are in, or somewhere global, this endless loop. eg Response.Redirect("Login.aspx");

Share:
27,248
Todd Zetlan
Author by

Todd Zetlan

Updated on December 10, 2020

Comments

  • Todd Zetlan
    Todd Zetlan over 3 years

    I have an ASP.NET 4.5 webforms site and trying to setup forms authentication. I have an Account folder with a Login.aspx page within. The main web.config contains the following:

    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
    </authentication>
    <authorization>
      <deny users ="?" />
      <allow users = "*" />
    </authorization>
    

    When I browse to the site, it appropriate redirects to Account/Login.aspx and then throws a browser error indicating

    Too Many Redirects

    . I am at a loss as to what could be wrong or where to go to troubleshoot next. Any assistance would be appreciated.

  • Todd Zetlan
    Todd Zetlan over 10 years
    I appreciate your response. Unfortunately, that did not resolve the problem.
  • Todd Zetlan
    Todd Zetlan over 10 years
    I did in fact find the root cause. Because I started with the WebForms template, VStudio setup an Account folder with a bunch of files to manage authentication, etc. There was code in the StartupAuth that was causing the issue. I ripped all of this out and was able to get the redirect working...sort of. When I configure the web.config to point the loginUrl to an html page in the root of the web app, it redirects. When pointing to an ASPX, it indicates "access is denied". If this should be a new thread, I will do so.
  • Todd Zetlan
    Todd Zetlan over 10 years
    Just to close this out, I found my issue with the access denied. I had the loginUrl in my web.config set to Login.aspx and denying anonymous access to everything. I also have friendly URLs on. By changing my loginUrl to Login (eliminating the extention), it fixed my issue.