Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC4 Error-No route in the route table matches
    primarykey
    data
    text
    <p>I am new to programming with C# and MVC4 the error happens at </p> <pre><code>@{ Html.RenderAction("Menu", "Nav"); } </code></pre> <p>It is coming back with an error stating that there is no route in the route table matches the supplied values. I have tried searching the internet to no avail, any help would be greatly appreciated. Thanks</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8" /&gt; &lt;meta name="viewport" content="width=device-width" /&gt; &lt;title&gt;@ViewBag.Title&lt;/title&gt; &lt;link href="~/Content/Site.css" type="text/css" rel="stylesheet" /&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="header"&gt; &lt;div class="title"&gt;Bag Labels&lt;/div&gt; &lt;/div&gt; &lt;div id="categories"&gt; @{ Html.RenderAction("Menu", "Nav"); } &lt;/div&gt; &lt;div id="content"&gt; @RenderBody() &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This is the _Layout.cshtml</p> <p>Here is my NavController.cs</p> <pre><code>using NavisionStore.Domain.Abstract; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace NavisionStore.WebUI.Controllers { public class NavController : Controller { private IProductRepository repository; public NavController(IProductRepository repo) { repository = repo; } public PartialViewResult Menu(string category = null) { ViewBag.SelectedCategory = category; IEnumerable&lt;string&gt; categories = repository.Products .Select(x =&gt; x.Category) .Distinct() .OrderBy(x =&gt; x); return PartialView(categories); } } } </code></pre> <p>Here is my RouteConfig.cs</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; namespace NavisionStore.WebUI { public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute(null, "", new { controller = "Product", action = "List", category = (string)null, page = 1 } ); routes.MapRoute(null, "Page{page}", new { controller = "Product", action = "List", category = (string)null }, new { page = @"\d+" } ); routes.MapRoute(null, "{category}", new { controller = "Product", action = "List", page = 1 } ); routes.MapRoute(null, "{category}/Page{page}", new { controller = "Product", action = "List" }, new { page = @"\d+" } ); routes.MapRoute(null, "{contoller}/{action}"); } } } </code></pre> <p>Here is my ProductController.cs</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using NavisionStore.Domain.Abstract; using NavisionStore.Domain.Entities; using NavisionStore.WebUI.Models; namespace NavisionStore.WebUI.Controllers { public class ProductController : Controller { private IProductRepository repository; public int PageSize = 1; public ProductController(IProductRepository productRepository) { this.repository = productRepository; } public ViewResult List(string category, int page = 1) { ProductsListViewModel ViewModel = new ProductsListViewModel { Products = repository.Products .Where(p =&gt; category == null || p.Category == category) .OrderBy(p =&gt; p.Id) .Skip((page - 1) * PageSize) .Take(PageSize), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = repository.Products.Count() }, CurrentCategory = category }; return View(ViewModel); } } } </code></pre>
    singulars
    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