【发布时间】:2014-06-26 10:17:40
【问题描述】:
如何在不使用 TemptData 的情况下重定向到另一个操作时传递模型数据,如示例中所示。 是否有另一种方法可以在不使用 TempData/Session 的情况下将 EmployeeViewModel 从“AddEmployee”操作传递到“Preview”操作?
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);
}
【问题讨论】:
-
L-3 我需要传递整个模型而不是字符串。模型有很多属性,包括集合、枚举值等,
标签: asp.net-mvc tempdata