This can be solved in several ways in each version of ASP.NET from version 1.0 and higher. I know this two years after the creation of this thread, but, in any case, here:
Cause
Creating a custom error handler or setting up a custom page in IIS for 404 redirects will not work. The reason is because ASP.NET considers this URL to be dangerous. Internally, in System.Web.Util.FileUtil ASP.NET calls the private method IsSuspiciousPhysicalPath , which attempts to map the path to the (virtual, but legal) file name.
When the received legalized path is not equal to the original path, processing stops, and ASP.NET code returns 404 (it does not request IIS or web.config for user 404, it returns one of them that makes it so difficult to do something with this).
Windows Explorer works the same. Try creating a file name ending in one or more points, i.e. test.txt. . You will see that the resulting name is text.txt .
Solution for final URL in point in ASP.NET
The solution is simple (as soon as you know it, it always is). Before sending this 404 message, he will select Application_PreSendRequestHeaders , a simple event that you can register in Global.asax.cs (or the VB equivalent). The following code will return plain text to the browser, but redirection or any other valid answer is also possible.
protected void Application_PreSendRequestHeaders(object sender, EventArgs e) { HttpResponse response = this.Context.Response; HttpRequest request = this.Context.Request; if (request.RawUrl.EndsWith(".")) { response.ClearContent(); response.StatusCode = 200; response.StatusDescription = "OK"; response.SuppressContent = false; response.ContentType = "text/plain"; response.Write("You have dot at the end of the url, this is allowed, but not by ASP.NET, but I caught you!"); response.End(); } }
Note: this code also works when "aspx" is not part of the url. Ie, http://example.com/app/somepath . will cause this event. Also note that some paths will not work anyway (ending with a few dots, with a hash tag or, for example, <-sign, causes a 400-Bad Request). Again, it works to complete a quote, space + slash, or multiple dots separated by spaces.