public ActionResult LogIn(UserDetail user)
{
using (AdventureWorksDBEntities User = new AdventureWorksDBEntities())
{
var UserInput= User.UserDetails.Where(b => b.UserName == user.UserName && b.Password == user.Password).FirstOrDefault();
if (UserInput!=null)
{
Session["Id"] = UserInput.id.ToString();
Session["UserName"] = UserInput.UserName.ToString();
return Redirect("#");
}
else
{
ModelState.AddModelError("","Username or Password Doesn't Exist");
}
}
return View();
我想将用户输入值与数据库中的值进行比较。