I'm trying to send the next to a C#
controller:
www.page.com/app/codes/10/status
The parameter is 10
and status
is the method.
if I send www.page.com/app/codes/status/10
the status before the parameter is working fine, but not in the other way.
I tried to configure the routes to be like
routes.MapRoute(
name: "codes",
url: "{controller}/{id}/status",
defaults: new { controller = "codes", action = "Status", id = UrlParameter.Optional }
);
and
routes.MapRoute(
name: "codes",
url: "codes/{id}/status",
defaults: new { controller = "codes", action = "Status", id = UrlParameter.Optional }
);
but none of them is working.
Any idea? Thanks.
Solution found thanks to @John @Nkosi and @Kobi
Basically from this one remove id = UrlParameter.Optional
routes.MapRoute(
name: "codes",
url: "{controller}/{id}/status",
defaults: new { controller = "codes", action = "Status" }
);
also i moved this route to the first place.
and its working fine.