5
Reply

Not Getting Data Nullable Exception

Yogesh Vedpathak

Yogesh Vedpathak

Jan 12 2018 5:20 AM
141
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)