ASP.NET MVC treats dot character as a literal for routes for a long time. However it doesn't match the route if the dot is at the end of the given route part.
Given the route {controller}/{action}/{id}
MVC matches these:
http://test/somecontroller/someaction/some.id
http://test/somecontroller/someaction/....some.id
But not these:
http://test/somecontroller/someaction/someid.
http://test/somecontroller/someaction/someid...
My requirement is to have arbitrary number of dots anywhere in the id section. Is there a way to work this around or is it a known situation that we need to avoid? It seems to me an MVC 2 bug.
P.S. You can also reproduce the same behavior on StackOverflow by adding dots to the question string in the URL at different places.
EDIT: Sorry this seems to be duplicate of "The resource cannot be found." error when there is a "dot" at the end of the url . I couldn't find it myself before.
If you are using .NET 4.0, you can set this flag in the system.web section of your web.config and it will be allowed:
<httpRuntime relaxedUrlToFileSystemMapping="true" />
I've tested it and it works. Haack has an explanation of it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With