跟踪this问题之后,缺少方法SignOut()SignIn()的引用:

private async Task SignInAsync(User user, bool isPersistent)
{
    AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
    var identity = await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
    AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
}

有人知道如何解决吗?

最佳答案

您如何定义AuthenticationManager属性?通常,它应该如下所示:

private IAuthenticationManager AuthenticationManager
{
  get
  {
    return HttpContext.GetOwinContext().Authentication;
  }
}

这样,您应该能够调用SignOut和SignIn方法。

10-07 21:41