在我的MVC项目开始时,我希望构建一个会员系统,并使用Membership.ValidateUser方法来验证凭据。然而,我无法理解这个方法如何访问我的数据库并检查我的电子邮件和密码信息。
[HttpPost]
[ActionName("Login")]
public ActionResult Login(LoginModel loginModel)
{
if (Membership.ValidateUser(loginModel.Email, loginModel.Password))
{
FormsAuthentication.SetAuthCookie(loginModel.Email, true);
return Json(true);
}
return new JsonNetResult()
{ Data = new { Error = true, Messages = new[] { new { Message = "Wrong username or password" } } } };
}