视图中的MVC3负载控制器

时间:2011-03-24 14:59:15

标签: asp.net-mvc-3 view controller

我正在尝试加载页面,在该视图中,我想从另一个检索信息的控制器加载另一个视图。 我可以用:  @ Html.Partial( “奥瑟维尤”) 适用于不需要数据但我希望页面检索数据的页面,所以使用: @ Html.Action( “奥瑟维尤”) 我认为应该工作,但不会,我得到一个HttpException

“执行处理程序'System.Web.Mvc.HttpHandlerUtil + ServerExecuteHttpHandlerAsyncWrapper'的子请求时出错。”

必须有办法做到这一点,

由于 Kelv

2 个答案:

答案 0 :(得分:1)

使用

 @Html.Action("otherView", "otherController", new { vm = viewModel })

并在控制器中创建一个动作

public ActionResult otherView(otherViewModel vm)
{
    return PartialView("otherView", vm);
}

答案 1 :(得分:0)

听起来你正在寻找RenderAction。

Here's the first article I found on the subject.

相关问题