12

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.

Community
  • 1
  • 1
Sedat Kapanoglu
  • 46,641
  • 25
  • 114
  • 148

1 Answers1

12

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.

bkaid
  • 51,465
  • 22
  • 112
  • 128
  • 1
    what about IIS 6 and ASP.NET 4.0? I still have this error at production (iis6) but not at my machine (iis7) – Serhiy Sep 05 '11 at 22:22
  • Сергій, did you resolve your issue? I have the same problem: http://stackoverflow.com/questions/9336569/iis-6-not-allowing-periods-in-the-querystring – Roger Feb 17 '12 at 23:02
  • Solved the problem for me too! Thanks =] – Luís Sousa Jan 20 '14 at 12:13