Route pattern cannot start with '/' or> '~', and it cannot contain '?' the character
I am getting an exception with the following route attribute:
[Route("{id}?action=decline")]
An exception:
An exception of type "System.ArgumentException" occurred in System.Web.Http.dll but was not handled in user code.
Additional information: Route pattern cannot start with '/' or '~', and it cannot contain ?? character.
Why is it not allowed?
+3
source to share
1 answer
I think this is not valid because the query string is not part of the URI Path. (See RFC3986 Section 3.3 Path , it does not include the request part)
But I cannot prove that: /. Perhaps these links will help you:
Routing based on
QueryString parameter name with MVC 5 AttributeRouting in Web API 2
Attribute Routing in ASP.NET Web API 2
+2
source to share