我有一个 UserManager 模型。它看起来像:
public class UserManager
{
private ToLetDBEntities TLE = new ToLetDBEntities();
public string GetUserPassword(string usermail)
{
var user = from o in TLE.users where o.email_add == usermail select o;
if (user.ToList().Count > 0)
{
return user.First().password;
}
else
return string.Empty;
}
}
我有一个 AccountController 像:
public class AccountController : Controller
{
[HttpPost]
public ActionResult LogOn(UserLogOn model)
{
if (ModelState.IsValid)
{
UserManager um = new UserManager();
string pass = um.GetUserPassword(model.email_add);
if (model.password==pass)
{
FormsAuthentication.SetAuthCookie(model.email_add, false);
return RedirectToAction("Welcome", "Home");
}
else
{
ModelState.AddModelError("", "The provided password is incorrect.");
}
}
return View(model);
}
}
我有一个 UserLogon 模型包含(email_add,密码)。当我运行此控制器时,它总是给我“提供的密码不正确”错误消息。if(model.password==pass) 这个条件总是给出假的。请任何人帮助我。在此先感谢..