0

Explanation

In production and locally, the 404 page for my site works fine for the most part. A URL such as http://localhost:43424/gibberish_r3hjjnwef will return the well designed 404 HTML page that is in the website folder, and pointed to by IIS.

However when I change the this URL to http://localhost:43424/gibberish_r3hjjnwef... it gives the following "hard" error, whilst still claiming to be a 404.

Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /gibberish_r3hjjnwef...

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2110.0

I'd rather it still gave the 404 HTML page.

I thought maybe it was an outright invalid URL, but both http://www.bbc.co.uk/news/fdisdhfdu and http://www.bbc.co.uk/news/fdisdhfdu... give the BBC's nice 404 page.

Question

Is there anything I can do to improve this?

Relevant Information (happy to provide more if necessary)

Microsoft .NET Framework Version: 4.0.30319

ASP.NET Version: 4.7.2110.0

Language/Framework:C#/Classic .ASP

Geesh_SO
  • 2,156
  • 5
  • 31
  • 58
  • classic asp? or asp.net? – The Bearded Llama Nov 17 '17 at 10:35
  • Ah, sorry, it's just Classic ASP judging by my quick Google. I'll update. – Geesh_SO Nov 17 '17 at 10:37
  • nw, update the tags as well ;) – The Bearded Llama Nov 17 '17 at 11:41
  • Sorry, I didn't read your question correctly. I can confirm your issue, but what is causing it is really the dots '...' in the URL. Check this: https://stackoverflow.com/questions/11728846/dots-in-url-causes-404-with-asp-net-mvc-and-iis – Efrain Nov 17 '17 at 12:26
  • 1
    This lead to my answer, thank you. It was due to the fact that ending with dots is not valid for NTFS directories. I could have `relaxedUrlToFileSystemMapping` but this is apparently insecure, so I'll just rewrite URLs to remove the dots at the end. Cheers! – Geesh_SO Nov 17 '17 at 14:47

1 Answers1

1

I'm not sure whether this is what you are referring to, but maybe try this out:

Go to IIS Manager -> Site -> IIS Error pages. On the right hand panel, there's a setting "Edit Feature Settings...".

The options there mean:

  • Custom error pages: Use the 'IIS error pages' as fallback for all failed requests (e.g. your 404 page set up the list behind)
  • Detailed error pages: In case of an Asp.Net error, shows the 'Asp.Net error page' ("Server Error in '/' Application." etc.)
  • Detailed errors for local requests etc.: Show the 'IIS error page' for remote requests, for local requests show the 'Asp.net error page' ("Server error in '/' etc.)

This is in place to effectively hide the detailed Asp.net error page (with the stack trace etc.) from external callers as you may not want to give them the details of your application. This is the default setting, where you should only see the 'Asp.net error page' when you call the invalid URL on 'localhost', but the 'IIS error page' (404) when you call the page from a different computer.

So, what you may want to try is to select the "Custom error pages" option ('IIS error pages' for all failed requests).

Efrain
  • 3,248
  • 4
  • 34
  • 61
  • Hi Efrain, thanks for the suggestion. It looks like it's already set to "Custom error pages" unfortunately, though. – Geesh_SO Nov 17 '17 at 11:05