Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you just need a piece of HTML on every page you can use <strong>partial view</strong> like this:</p> <pre><code>@Html.Patial("_Menu") </code></pre> <p>instead of </p> <pre><code>@{ Html.RenderAction("Menu", "Nav"); } </code></pre> <p>Here <strong>_Menu</strong> is name of partial view <strong>_Menu.cshtml</strong> (should be placed in Views/Shared)</p> <p><strong>UPDATE 1</strong></p> <p>If you need pass some object (lets say <em>collection</em>) to the partial view just specify it as second parameter:</p> <pre><code>@Html.Patial("_Menu", collection) </code></pre> <p><em>collection</em> object will be your model in <strong>_Menu.cshtml</strong> view, so you can use it as usual:</p> <pre><code>@model System.Collections.Generic.IEnumerable&lt;string&gt; &lt;select&gt; @foreach(var item in Model) { &lt;option&gt;@item&lt;/option&gt; } &lt;/select&gt; </code></pre> <p><strong>UPDAET 2</strong></p> <p>Also your routes rules are too weird. Why don't you use default routing only:</p> <pre><code>routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Product", action = "List", id = UrlParameter.Optional } ); </code></pre> <p>This will allow you to call your action like this:</p> <ul> <li><strong>.../nav/menu</strong></li> <li><strong>.../product/list</strong></li> <li><strong>.../</strong> which will equals to <strong>.../product/list</strong> since default controller was set to <strong>ProductController</strong> and default action was set to <strong>List</strong> method.</li> </ul> <p>Any way in route rule you always have to specify <strong>unique</strong> name and template. But you are passing empty string as rule name - it's wrong. You should replace whole your <strong>RouteConfig.cs</strong> as @user65439 mentioned in his answer.</p>
 

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