2

I have a custom route:

<Route("maintenance/test/{one}/{two}/{three}")>
Function Test(ByVal one As String, ByVal two As String, ByVal three As String) As JsonResult
    Return Json(True, JsonRequestBehavior.AllowGet)
End Function

When I hit the route it works as expected:

localhost:1337/maintenance/test/1/2/3

However, if any of the parameters contains a period, such as:

localhost:1337/maintenance/test/1/2./3 (note period after 2)

I get a 404 "The resource cannot be found" error.

It seems IIS is picking up the URL and trying to serve a static file instead of passing it onto MVC.

Things I've tried (to no avail):

  • Adding a trailing slash to force IIS to recognize it as a URL and not a resource
  • Adding runAllManagedModulesForAllRequests="true" to web.config's <system.webServer><modules> as per this answer.
  • Adding a TransferRequestHandler handler as per [this answer]:(https://stackoverflow.com/a/12151501/118697)
    <add name="ApiURIs-ISAPI-Integrated-4.0" 
         path="/people/*" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" 
         type="System.Web.Handlers.TransferRequestHandler"
         preCondition="integratedMode,runtimeVersionv4.0" />
  • Updating MVC 5 to the latest (5.2.3)
Community
  • 1
  • 1
Chad Levy
  • 10,032
  • 7
  • 41
  • 69

1 Answers1

1

My original assumption that IIS was treating the request as a resource request was incorrect.

It turns out ASP.NET blocks any request for a URL with a ./ in the same way it blocks legacy reserved words.

The solution then is to enable relaxedUrlToFileSystemMapping:

<httpRuntime relaxedUrlToFileSystemMapping="true" />

Sources:

Community
  • 1
  • 1
Chad Levy
  • 10,032
  • 7
  • 41
  • 69