Trailing dots in url result in empty 404 page on IIS

Adding this attribute in the httpRuntime section may help you:

<configuration>
  <system.web>
    <httpRuntime ... relaxedUrlToFileSystemMapping="true" .../>
  </system.web>
</configuration>

Gets or sets a value that indicates whether the URL in an HTTP request is required to be a valid Windows file path.

More information about relaxedUrlToFileSystemMapping


There is a KB about this: http://support.microsoft.com/kb/2520479

The upshot of it is that there is an order-of-operations issue where the .NET handlers for various functions get mixed up and misdirect things. Some of the .NET handlers re-write the URL to an extension-less form and they can freak out other things.

The short workaround fix is to move all the "ExtensionlessUrlHandler" handlers to the very end of the list, after any custom ones you have added that might touch the PathInfo data.

It may not be your exact error but it is well worth trying. And worth remembering that the handler order is configured by the ADD order in ApplicationHost.Config and related config files!


I can't give you an answer about why the dotnet framework exhibits this annoying behaviour. It's almost as though it treats the 404 as a handled 404 and skips the default IIS 404 page. Perhaps it sets:

Response.IisTrySkipIisCustomErrors

Microsoft docs

Anyway when I implemented your rule, I tweaked your regular expression to support a trailing . followed by an optional /.

e.g.

https://localhost/investing./

I have updated it to support an optional slash.

<rule name="Trailing Dots" stopProcessing="true">
    <match url="\.+/?$" />
    <action type="Rewrite" url="/404.html" appendQueryString="false" />
  </rule>

I would have added this as a comment, but don't have the rank to do this.