As noted in the comment by @AlexeiLevenkov, this is wrong:
You cannot have a parameter in the URL which accepts forward slashes, because this is a special symbol which separates each URL fragment. So, whenever you include this symbol in your URL, there will be new fragments, and a single parameter can't include several fragments.
If you want more details, read this, but these are the most relevant excerpts:
- the URL path finishes in the first
?
or #
found in the URL. So, the slashes only create fragments in the section of the URL path before the occurrence or one of those symbols.
- From section 3.4: The query component is indicated by the first question mark ("?") character and terminated by a number sign ("#") character or by the end of the URI.
So, the query string can include forward slashes, /
, if desired, and they will not define path segments at all.
These are some solutions for the question:
- include fragments for day, month and year, like this:
[Route("orders/{month}/{day}/{year}/customers")]
and then create the date on the server side
- require the user to use a different separator, like dash or dot, which won't create problems, receive it at string an parse it yourself (or use your own custom binder to support that format)
- use the URL Rewrite extension to change the URL before it reaches the routing system, and parse it as explained in the previous solution (this requires hosting in IIS)
- receive it as a query string, i.e. something like this: ´?date=02/03/2015´ (you'd better encode it)
NOTE: your original question said "query string", and my comment about encoding referred to the query string, which is the last segment of an URL after the question mark, if present, like &id=27
. I corrected your question so that it doesn't mention "query string", which was not the right name for what you need
*
in{*orderdate}
. This actually solved my problem, as my parameter was at the end of the URL. – Dira