【发布时间】:2013-07-29 11:26:43
【问题描述】:
在我的项目中,我有两个不同的控制器。
这是主要的:
public class Main : Controller
{
public ActionResult Index()
{
return View();
}
}
这是另一个:
public class OtherOne : Controller
{
public ActionResult RandomAction()
{
return ... //more code here
}
}
我应该在 "OtherOne/RandomAction" 中返回什么以获得与 "Main/Index" 操作相同的结果?
【问题讨论】:
-
你想达到什么目的?像“主/索引”这样的相同结果是什么意思。如果两个动作方法具有相同的逻辑,为什么你有两个动作?最简单的方法是使用 RedirectToAction 并将数据存储在可以在 Main/Index 中访问的 TempData 集合中。
标签: c# asp.net-mvc asp.net-mvc-3 http-redirect