我试图修改在 Visual Studio 2013 sp 3 上创建新 mvc 项目时自动创建的登录系统。当我注册我的用户时,我去
await SignInAsync(user, isPersisten:false);
去:
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);
}
即使我的用户对象充满了信息并且 ApplicationCookie = ApplicationCookie 我仍然在 UserManager.CreateIdentityAsync 上得到 NullReferenceException。