1
我想更好地瞭解.NET的Identity OnValidateIdentity方法是如何工作的。我已成立了這段代碼在我的應用程序類似以下內容:OnValidateIdentity ASP.NET Identity如何工作
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
CookieName = "LoginCookie",
ExpireTimeSpan = TimeSpan.FromHours(1),
Provider = new CookieAuthenticationProvider
{
// Enables the application to validate the security stamp when the user logs in.
// This is a security feature which is used when you change a password or add an external login to your account.
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromHours(1),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
不OnValidateIdentity這裏有一定的作用,當用戶訪問我的網站怎麼看老就是他的cookie來檢查,如果它是一個比舊的那我已經在這裏設置了(這是1小時) - 用戶將被迫重新登錄到應用程序中。
這是如何工作的?