7
我有2个控制器,SearchController
和DetailsController
。如何在mvc4中调用另一个控制器的视图
SearchController
包含2个视图,其中包含表单。
我想重定向到的细节控制器的看法对我的看法在SearchController
的[HttpPost]
行动这是可能的???
我有2个控制器,SearchController
和DetailsController
。如何在mvc4中调用另一个控制器的视图
SearchController
包含2个视图,其中包含表单。
我想重定向到的细节控制器的看法对我的看法在SearchController
的[HttpPost]
行动这是可能的???
如果您正在第一个控制器中执行一些处理,然后将结果发送到另一个控制器,则可以尝试RedirectToAction。
查看
using(@Html.BeginForm("firstaction", "search", FormMethod.Post)){
// form stuff
}
控制器
public class SearchController
{
[HttpPost]
public ActionResult FirstAction()
{
// do initial processing in the first controller
// e.g persisting changed on Edit Screen
return RedirectToAction("SecondAction","Details");
}
}
public class DetailsController
{
public ActionResult SecondAction()
{
// do remaining processing in the first controller
// fetching data for a grid and displaying the grid of items
return View();
}
}
您通过返回[RedirectResult]的意思(http://msdn.microsoft.com/en-us/library/system。 web.mvc.redirectresult(v = vs.108)的.aspx)? – rene