【问题标题】:Why call SignOut(DefaultAuthenticationTypes.ExternalCookie) before use of ApplicationCookie with ASP.Net Identity?为什么在将 ApplicationCookie 与 ASP.Net Identity 一起使用之前调用 SignOut(DefaultAuthenticationTypes.ExternalCookie)?
【发布时间】:2013-12-13 14:55:42
【问题描述】:

为什么此示例在使用 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);
}

【问题讨论】:

    标签: c# asp.net asp.net-identity


    【解决方案1】:

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

    【讨论】:

    猜你喜欢
    • 2014-04-27
    • 2019-06-05
    • 1970-01-01
    • 2015-07-26
    • 2019-08-30
    • 1970-01-01
    • 2019-11-02
    • 1970-01-01
    • 2015-08-18
    相关资源
    最近更新 更多