Yogesh Vedpathak

Yogesh Vedpathak

  • 675
  • 1.4k
  • 192k

Not Getting Data Nullable Exception

Jan 12 2018 5:20 AM
public ActionResult Logout(UserProfile objUser)
{
{
if (ModelState.IsValid)
{
using (SessionEntities Db = new SessionEntities())
{
var obj = Db.UserProfiles.Where(a => a.UserName.Equals(objUser.UserName) && a.Password.Equals(objUser.Password)).FirstOrDefault();
if (obj != null)
{
Session["UserName"] = objUser.UserName.ToString();
// Session["UserName"] = obj.UserName.ToString();
// Session.Remove(a.ToString());
Session.Abandon();
return RedirectToAction("Login");
}
else
{
return RedirectToAction("Admin");
}
}
}
}
return RedirectToAction("UserDashBoard");
}

Answers (5)