Dot character in ASP.NET MVC 3 route parameters

2019-01-26 00:06发布

问题:

I have no custom routes in my application, only the default one. If i try to open localhost/myapp/controller/action/bla.bla it works fine on my machine (Windows 7 x32, both Cassini and IIS) but fails on the server (2008 R2 x64). Found similar question but the solution doesn't work. Also, found this article where Eilon says it's a special character for MVC and it's "by design". Why there is difference between my machine and the production box and how do i fix it?

Update: the problem site has ExtensionlessUrl-ISAPI-4.0_64bit and ExtensionlessUrl-Integrated-4.0 enabled and mapped to "*.". There are no any managed handlers in web.config. The patch mentioned by Dmitry "is not applicable to your computer", probabaly because it's already installed with SP1. I can confirm that 404 is reported back by ASP.NET MVC, not IIS because i can see the request in Application_PreSendRequestHeaders. Moreover, if i attach a descendant of MvcRouteHandler with overloaded GetHttpHandler() that logs all RouteData it shows that "id" is correctly mapped to "bla.bla". Any ideas?

回答1:

Is the application using any managed handlers that are mapped to the "*." extension? If so, check out this link:

http://support.microsoft.com/kb/980368



回答2:

This work for me:

<system.webServer>
<handlers>
  <add name="UrlRoutingHandler"
     type="System.Web.Routing.UrlRoutingHandler, 
           System.Web, Version=4.0.0.0, 
           Culture=neutral, 
           PublicKeyToken=b03f5f7f11d50a3a"
     path="/Users/*"
     verb="GET"/>
</handlers>
</system.webServer>


回答3:

Can you find what errors(exceptions) if any are you getting by seeing all first chance exceptions. This will show you how can find all the first chance exceptions your application is throwing.



回答4:

There is an new update available for Win2k8r2sp1, have a look at

http://www.shanmcarthur.net/Default.aspx?DN=7d0cd525-bbc5-46c3-8096-95f93827aeea



回答5:

Please provide more detail, like what were the expected result, what errors do you get. Which solutions have you tried so far? Have you tried the configuration solution?

<httpRuntime relaxedUrlToFileSystemMapping="true" />

As to, "Why there is a difference between my machine and the production box"... Well my friend, that is a question only you can answer.



回答6:

All the latest Windows updates (after SP1) seem to solve the issue.