Interviews3 answers
What is syntax for Tempdata in MVC ?
3 Answers
******* 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);
}
Ritesh SinghPosted Aug 4, 2016, 9:46 AM EDT
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
Ritesh SinghPosted Aug 4, 2016, 9:46 AM EDT
The syntax for Tempdata in MVC is
Tempdata["variable "]=value;
Sandeep KumarPosted Dec 26, 2015, 8:41 AM EST

