public ActionResult Index(user objchk) { if (ModelState.IsValid) { using (Students_DataEntities db = new Students_DataEntities()) { var obj = db.users.Where(a => a.username.Equals(objchk.username) && a.password.Equals(objchk.password)).FirstOrDefault(); if (obj != null) { Session["UserId"] = obj.user_id.ToString(); Session["UserName"] = obj.username.ToString(); return RedirectToAction("Index", "Home"); } else { ModelState.AddModelError("", "The User Name or Password Incorrect"); } } } return View(objchk); }