I have an ActionResult that I have applied a routing attribute to:
[Route("myproduct/{productID}", Name = "myproduct")]
[MvcSiteMapNode(Title = "Products", ParentKey = "products", Key = "myproducts")]
public ActionResult myproducts(int productID) ...
I am trying to link to the view via a RouteUrl:
<a href="@Url.RouteUrl("myproducts", @Model.myproducts[i].productID)">Buy</a>
The resulting html does not even include a href:
<a>Buy</a>
If I remove the parameter it works:
[Route("myproducts", Name = "myproducts")]
[MvcSiteMapNode(Title = "Products", ParentKey = "home", Key = "myproducts")]
public ActionResult myproducts(int productID) ...
<a href="/products/myproducts">Book</a>
Am I trying to add the parameter incorrectly? The documentation suggests what I am attempting.
Route Config:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapMvcAttributeRoutes();
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}