Reputation: 4484
I'm trying to take a url that looks like this
competitors/edit/d2d01443-118c-4a35-a783-465505f8d786?accountid=6af99691-2275-4629-8542-2eb52a34893f
and convert it to something like this. Essentially taking just moving the account id parameter before the competitor parameter.
/competitors/edit/6af99691-2275-4629-8542-2eb52a34893f/d2d01443-118c-4a35-a783-465505f8d786
I've tried adding this route to the top of the route config but I just get a 404 error when I try the new url. Can anyone point out what I'm doing wrong? Thanks!
routes.MapRoute(
name: "Competitors",
url: "{controller}/{action}/{accountid}/id",
defaults: new { controller = "Competitors", action = "Edit", accountid = UrlParameter.Optional, id = UrlParameter.Optional });
Upvotes: 0
Views: 38
Reputation: 16743
I believe you need braces around all your segments, otherwise "id" would need to be hardcoded into the URL for it to match:
routes.MapRoute(
name: "Competitors",
url: "{controller}/{action}/{accountid}/{id}",
defaults: new { controller = "Competitors", action = "Edit", accountid = UrlParameter.Optional, id = UrlParameter.Optional });
Upvotes: 1