CookieAuthenticationOptions, ExpireTimeSpan does not work

前端 未结 2 1483
深忆病人
深忆病人 2021-02-07 01:02

I have the following code:

    public void ConfigureAuth(IAppBuilder app)
    {
        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            


        
2条回答
  •  爱一瞬间的悲伤
    2021-02-07 01:36

    You must set IsPersistent to true otherwise you don't run code

        ClaimsIdentity claimsIdentity = new ClaimsIdentity(Claims, CookieAuthenticationDefaults.AuthenticationScheme);
    
                    var authProperties = new AuthenticationProperties
                    {
                        IsPersistent = true
    
                    };
    
                    await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity), authProperties);
    

提交回复
热议问题