为什么在将ApplicationCookie与ASP一起使用之前调用SignOut(DefaultAuthenticat
本文关键字:调用 SignOut DefaultAuthenticat ApplicationCookie 一起 ASP 为什么 | 更新日期: 2024-09-25 15:01:01
为什么此示例在使用ApplicationCookie登录之前调用ExternalCookie的SignOut?这只是确保身份验证信息干净的一种方法吗?(完整示例如下:http://www.asp.net/identity/overview/getting-started/introduction-to-aspnet-identity)
private async Task SignInAsync(ApplicationUser user, bool isPersistent)
{
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
var identity = await UserManager.CreateIdentityAsync(
user, DefaultAuthenticationTypes.ApplicationCookie);
AuthenticationManager.SignIn(
new AuthenticationProperties() {
IsPersistent = isPersistent
}, identity);
}
它基本上是清理的,外部cookie最终应该会被清除,它只需要存储从google/fb/twitter等返回的声明,这样应用程序就可以在签署用户之前提取所需的任何数据。因此,SignIn是清除外部数据的一个安全的好地方。