ASP.NET MVC3 - Html.RenderAction not working
asp.net-mvc-3
Solution
Your `header.cshtml` look's rare to me, but if you want to make your header view as a partial view
First:
Remove the layout using
@{
Layout = null;
}
Second To render this view on your layout use
@Html.Action("Header","Home", new { foo= @someElement}) <-- this element send values to your action
Problem
I'm developing a layout page in MVC application. The layout page has - Header - Content - Footer Header has ogo, Welcome message, user info, several other links. My question is, Should i design header as partial view or render it using Rendoraction. PartialView is working fine. But as this data does not depend on rest of the page, i want to call a controller action which returns a header view with its own model. but HTML Rendor action is not working. _Layout.cshtml ``` <body> <div class="main_page"> <div id = "header"> *@Html.Partial("HeaderPartial", @Model)*@ @Html.Action("Header") </div> <div id="body"> @RenderBody() </div> <div id="footer"> </div> </body> ``` HomeController ``` public ActionResult Header() { Var VModel = //Create Model; return View(VModel) } ``` header.cshtml ``` @model VModel <div> </div> ``` Error executing child request for handler System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper