Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC 3 Partial View in layout page
    primarykey
    data
    text
    <p>I'm working on setting up a shared content (navigation) for an asp.net MVC layout page.</p> <p>Here is my partial view "_LayoutPartial.cshtml" with code to pull navigation data from a model.</p> <pre><code>@model MyApp.Models.ViewModel.LayoutViewModel &lt;p&gt; @foreach (var item in Model.navHeader) { //Test dump of navigation data @Html.Encode(item.Name); @Html.Encode(item.URL); } &lt;/p&gt; </code></pre> <p>Here is how the code for my controller "LayoutController.cs" looks like.</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using MyApp.Models.ViewModel; namespace MyApp.Controllers { public class LayoutController : Controller { // // GET: /Layout/ LayoutViewModel layout = new LayoutViewModel(); public ActionResult Index() { return View(layout); } } } </code></pre> <p>Here is the code for the "_Layout.cshtml" page. I'm attempting to call the partial view here using Html.RenderAction(Action,Controller) method.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8" /&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt; @{Html.RenderAction("Index","Layout");} &lt;/p&gt; @RenderBody() &lt;/body&gt; &lt;/html&gt; </code></pre> <p>When the layout page executes the @{Html.RenderAction("Index","Layout");} line, it throws out an error message "Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'." </p> <p>What am I missing friends? How can I call a partial view in a layout page?</p> <p>Thank you all in advance!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload