Request.IsAuthenticated is always false

前端 未结 10 2128
迷失自我
迷失自我 2020-12-15 04:34

Can you tell me why FormsAuthentication.SetAuthCookie(user.Name, false); is not causing Request.IsAuthenticated to be true?

Here is my code

10条回答
  •  有刺的猬
    2020-12-15 05:31

    In my case I had this issue which ended up in a redirect-loop where the user would be redirected to the login, successfully logged in and then back to our site but since Request.IsAuthenticated was false the user was redirected to the login agan.

    In our case this was solved by using another CookieManager,

    var cookieOptions = new CookieAuthenticationOptions();
    cookieOptions.CookieManager = new SystemWebCookieManager(); 
    app.UseCookieAuthentication(cookieOptions);
    

    Turns out that there was some kind of bug in Katana that this other CookieManager worked around, in out case this solved the issue.

    https://github.com/aspnet/AspNetKatana/wiki/System.Web-response-cookie-integration-issues

提交回复
热议问题