Skip to main content

Example of how to generate a URL based on declared ASP.NET MVC 5 Controller Route Attributes.

// Controller action looks like:
[Route("myproducts/{productID}", Name = "myproducts")]
[MvcSiteMapNode(Title = "Products", ParentKey = "home", Key = "myproducts")]
public ActionResult myproducts(int productID) {
    // ...
}

// To generate the URL:
@Url.RouteUrl("myproducts", new { productID = Model.myproducts[i].productID })