为什么在使用带有ASP.Net Identity的ApplicationCookie之前调用SignOut(DefaultAuthenticationTypes.ExternalCookie)?

Jos*_*sso 5 c# asp.net asp.net-identity

为什么这个示例在使用ApplicationCookie登录之前调用SignOut for ExternalCookie?它只是确保身份验证信息干净的一种方法吗?(完整的例子在这里: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);
}
Run Code Online (Sandbox Code Playgroud)

Hao*_*ung 9

它基本上是清理,外部cookie应该最终被清除,它只需要存储从google/fb/twitter等返回的声明,这样app可以在签署用户之前提取它需要的任何数据.所以SignIn是一个清除外部数据的好地方.

  • 上下文解释/sf/ask/1831677851/ (3认同)