Home Dots in URL causes 404 with ASP.NET mvc and IIS
Reply: 0

Dots in URL causes 404 with ASP.NET mvc and IIS

user9768
1#
user9768 Published in September 21, 2018, 8:36 am

I have a project that requires my URLs have dots in the path. For example I may have a URL such as www.example.com/people/michael.phelps

URLs with the dot generate a 404. My routing is fine. If I pass in michaelphelps, without the dot, then everything works. If I add the dot I get a 404 error. The sample site is running on Windows 7 with IIS8 Express. URLScan is not running.

I tried adding the following to my web.config:

<security>
  <requestFiltering allowDoubleEscaping="true"/>
</security>

Unfortunately that didn't make a difference. I just receive a 404.0 Not Found error.

This is a MVC4 project but I don't think that's relevant. My routing works fine and the parameters I expect are there, until they include a dot.

What do I need to configure so I can have dots in my URL?

share|improve this question
  • 80
    Can't believe I spent so much time on this one. The URL works fine if I add a trailing slash. For example, www.example.com/people/michael.phelps/ however without the trailing slash IIS throws a 404 error. – Mark Jul 30 '12 at 21:51
  • 12
    Mark - that is because without the trailing slash, IIS thinks it is a file that it should go and find. Adding the slash has the effect of...this is not a real file. Additionally, the configuration option below tells IIS that if it is not a file, try to route it instead. – Tommy Jul 30 '12 at 22:39
  • I'm having the same problem after I updated my project to mvc 4 + asp.net 4.5. – Tadeu Maia Aug 21 '12 at 22:57
  • As a work around I'm using IIS Rewrite to add the trailing slash to my URLs. – Mark Aug 21 '12 at 23:11
  • 4
    This doesn't work for me. The URL works fine with "." within the URL but when it is at the very end it gives an error – Arcadian Feb 27 '15 at 14:48

16 Answers 16

active oldest votes
up vote 22 down vote
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.475778 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO