使用asp.net身份关闭浏览器后如何保留登录信息? [英] How to persist the login information after closing Browser using asp.net Identity?
问题描述
使用ASP.NET
身份时,我想在用户登录我的网站时尽可能长地保留登录信息,因此用户在重新打开浏览器时不需要再次登录(就像github .com和stackoverflow.com).当我登录到github时,它会保存我的信息很多天,因此我不需要每天都重新登录.是否可以使用ASP.NET
身份实现此功能的任何方法?
When using the ASP.NET
Identity, I want to persist the login information as long as possible when the user logs in to my website, so the user doesn't need to login again when they reopened their Browser (just like github.com and stackoverflow.com). When I login to github, it persists my information for many days, so I don't need to login again every day. Are there any methods can that can implement this functionality using ASP.NET
Identity?
推荐答案
只需将适当的值传递给SignIn方法的isPersistent
参数:
Just pass the appropriate value to the isPersistent
argument of the SignIn methods:
SignInManager.PasswordSignInAsync("email@id.com", "password", isPersistent: true, shouldLockout: false);
或
SignInManager.SignInAsync(applicationUser, isPersistent: true, rememberBrowser: false);
isPersistent
参数用于控制是否应保留用户的身份验证cookie.
The isPersistent
argument is used to control if the user's authentication cookie should be persisted.
rememberBrowser
参数用于双重身份验证":记住的浏览器可以直接使用密码直接登录.
The rememberBrowser
argument is used in case of Two Factor Authentication: a remembered browser can login directly with the password alone.
这篇关于使用asp.net身份关闭浏览器后如何保留登录信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!