0

How to pass model data while redirecting to another action without using TemptData, as given in the example. Is there an alternate way to pass EmployeeViewModel from "AddEmployee" action to "Preview" action without using TempData/ Session?

public ActionResult AddEmployee(EmployeeViewModel employeeViewModel)
{
  TempData["employee"] = employeeViewModel;
  return this.RedirectToAction("Preview");
}

public ActionResult Preview()
{
  var model = TempData["employee"] as EmployeeViewModel;
  return this.View("Preview", employeeViewModel);
}
m rajesh
  • 15
  • 6
  • Did you google? See http://stackoverflow.com/questions/3363842/asp-net-mvc-redirect-to-action-need-to-pass-data – L-Four Jun 26 '14 at 10:21
  • L-Three I need to pass the entire Model instead of string. Model has many properties including Collections, Enum values etc., – m rajesh Jun 26 '14 at 11:01

1 Answers1

0

check this

return RedirectToAction("Index", new { exception = EmployeeViewModel});