无法使用UserName和Email验证MVC 5身份验证

时间:2014-11-24 14:49:49

标签: c# asp.net asp.net-mvc forms-authentication asp.net-mvc-5.2

验证工作正常,但如果我更改帐户/注册

var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; 

var user = new ApplicationUser { UserName = model.UserName, Email = model.Email };

验证始终未通过帐户/登录

var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);

这是一个已知的错误还是我错过了什么

1 个答案:

答案 0 :(得分:0)

在您对SignInManger.PasswordSignInAsync的调用中,您仍然在发送电子邮件中作为您要用于验证的用户名而不是UserName属性。

 var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout: false);