Mahendra Kumar

Mahendra Kumar

  • NA
  • 164
  • 5.1k

The name ViewBag does not exist in the current context

Dec 28 2018 3:32 AM
[HttpPost]
public ActionResult Index(tblUser ob)
{
if (ob.emp_no != null && ob.pass != null && ob.pass != "")
{
if (ModelState.IsValid)
{
billMangeSys_Entities billentity = new billMangeSys_Entities();
var user = billentity.tblUsers.Single(x => x.emp_no == ob.emp_no && x.pass == ob.pass);
if (user != null)
{
// return View(user);
return RedirectToAction("dashboard");
}
}
}
else {
ViewBag.Message = string.Format("Hello {0}.\\nCurrent Date and Time: {1}", name, DateTime.Now.ToString());
}
return View();
}

Answers (3)