Reputation: 9527
According the asp.net documentation there is a property called RouteOrder
on the RouteAttribute
. However I can't find that in code. I can find Order
, but not RouteOrder
. Should I assume these are the same?
Upvotes: 4
Views: 378
Reputation: 53610
Yes, they are the same. I was following the same article and I ran into this problem (RouteOrder
does not exist in System.Web.Http.RouteAttribute
).
I did a quick test in my Web API 2 application to verify:
[Route("{name}")] // unconstrained parameter
[HttpPost]
public string Test(string data) {
return data;
}
[Route("preview")] // literal
[HttpPost]
public string Preview(string data) {
return data;
}
When I hit api/preview
with Fiddler, Preview()
is hit since literal segments are considered before parameter segments. If I change it to give less importance to the literal action:
[Route("preview"), Order = 1] // literal
[HttpPost]
public string Preview(string data) {
return data;
}
And hit api/preview
again, Test()
is hit, in line with the documented behavior of RouteOrder
. I have no idea why it was renamed, but it's the same thing!
Upvotes: 1