What is syntax for Tempdata in MVC ?
Sandeep Kumar
******* Set Temp Data *********** public ActionResult Index() {var model = new Test(){Name = "ABC",Salary=5000};TempData["ModelName"] = model;return RedirectToAction("About"); }******* Get Temp Data *********** public ActionResult About() { var model= TempData["ModelName"]; return View(model); }
Hi,******* Set Temp Data public ActionResult Index() {var model = new Test(){Name = "ABC",Salary=5000};TempData["ModelName"] = model;return RedirectToAction("About"); }******* Get Temp Data public ActionResult About() { var model= TempData["ModelName"]; return View(model); }Note: Please accept the answer if it help you and answer your question.Thanks & Regards, Ritesh
The syntax for Tempdata in MVC is Tempdata["variable "]=value;