Infinite redirect loop for Basic or Windows authentication?

前端 未结 5 577
长发绾君心
长发绾君心 2021-02-01 23:03

I am working on a new ASP.NET application. On IIS8, if I disable Anonymous access and enable Basic or Windows authentication, it goes into an infinite redirect loop and lands at

5条回答
  •  一向
    一向 (楼主)
    2021-02-01 23:54

    I fixed it. First thing that you have to do is enable Windows auth and disable anonymous on both IIS and your Visual Studio project (select the root project node in Solution Explorer and in the Property window to disable Anonymous access and enable Windows auth). Next, add the following line to your web.config:

    
      
        
        
      
    
    

    Next open up App_Start/Startup.Auth.cs and comment out (or delete) the following:

            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
    

    Next, publish to your webserver and you should be able to login without that redirect bug!

提交回复
热议问题