I have the following Custom URL Routing Rule:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"RaceRoute", // Route name
"people/create/{raceid}/{id}", // URL with parameters
new { controller = "People", action = "Create", raceid = UrlParameter.Optional, id = UrlParameter.Optional }
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
Which I'm trying to use with Actionlink
@Html.ActionLink("Add Person", "Create", "People", new { raceid = item.RaceId, id="1" })
I basically want the url to look like "/people/create/5/1"
But the HTML generated looks like
<a href="/races/Create?Length=6" id="1" raceid="5">Add Person</a>
It should say <a href="/people/Create/5/1">Add Person</a>
The page I'm on is http://localhost:57355/races
If I do just @Html.ActionLink("Add Person", "Create", "People") then it works but I get no parameters.
What am I missing?
Thanks