I am in the process of creating a prototype project using MVC 3 and I have come across a situation which I can\'t seem to find an answer for and it seems like I might be app
You can not use @RenderBody()
multiple times. One @RenderBody()
in your main _Layout file is fair enough. In your second view use instead @RenderPartial()
or @RenderAction
.
UPDATE (based on first comment)
Let's say you want to render /Administrator/TheAction
, so you will call
@{
Html.RenderAction("TheAction", "Administrator");
}
TheAction
action will look like this:
public PartialViewResult TheAction() {
return PartialView();
}
And it will render the view in ~/Views/Administrator/TheAction.cshtml
right inside the place from which you called the RenderAction()
.
The importance is that it does not accomplish another @RenderBody
. As you can see in TheAction()
example, you are returning PartialViewResult, which does not have any @RenderBody()
helper.