ASP.NET Identity 2 Remember Me - User Is Being Logged Out

后端 未结 5 806
南旧
南旧 2021-02-08 12:40

I am using Identity 2.1 in my MVC5 app. I am setting the isPersistent property of the PasswordSignInAsync to true to enable \'Remember Me\':

var result = await S         


        
5条回答
  •  盖世英雄少女心
    2021-02-08 13:30

    There is an explanation for TimeSpan parameter in similar question. Simply use the infinite cookies, like this:

    OnValidateIdentity = SecurityStampValidator
      .OnValidateIdentity(
      validateInterval: TimeSpan.FromMinutes(0),
      regenerateIdentity: (manager, user)
      => user.GenerateUserIdentityAsync(manager))
    

    This is also needed for it to work correctly:

    Call

    await UserManager.UpdateSecurityStampAsync(userId);
    

    before

    AuthenticationManager.SignOut(); 
    

提交回复
热议问题