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):
runAllManagedModulesForAllRequests="true"
to web.config's <system.webServer><modules>
as per this answer. <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" />
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: