KelvT
KelvT

Reputation: 1

MVC3 load controller in a View

I am trying to load a page and in that view i want to load another view from a different controller which retrieves information. I can use: @Html.Partial("otherView") which works for pages which require no data but i would like the page to retrieve data, so using : @Html.Action("otherView") i thought should work but does not and i get an HttpException

"Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'."

There must be a way of doing this,

Thanks Kelv

Upvotes: 0

Views: 3639

Answers (2)

3Dave
3Dave

Reputation: 29041

Sounds like you're looking for RenderAction.

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

Upvotes: 0

rucsi
rucsi

Reputation: 516

use

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

and in the controller create an action

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

Upvotes: 1

Related Questions