Yogesh Vedpathak

Yogesh Vedpathak

  • 682
  • 1.4k
  • 188.2k

Getting Null in var obj why ? How to solve This ??

Feb 27 2018 2:59 AM
public ActionResult Login(UserResgitartion objUser)
{
if (ModelState.IsValid)
{
using (MyDatabaseEntities Db = new MyDatabaseEntities())
{
var obj = Db.UserResgitartions.Where(a => a.UserName.Equals(objUser.UserName) && a.Password.Equals(objUser.Password)).SingleOrDefault<UserResgitartion>();
if(obj != null)
{
Session["UserID"]= obj.UserID.ToString();
Session["USERNAME"] = obj.UserName.ToString();
if (objUser.UserName == "Admin" && objUser.Password == "admin")
{
return View("AdminDashBoard");
}
else
{
return View ("UserDashBoard");
}
// return RedirectToAction("UserDashBoard");
}
}
}
return View(objUser);
}

Answers (4)