Why would an aspx file return 404 ("The page cannot be found")
I found a solution here. The real catch was using this:
Response.TrySkipIisCustomErrors = true;
I just happened to find another culprit for this issue. My foo.aspx
page referenced a particular master page that had a <%@ Register %>
directive to a user control that did not exist. Removing the reference to the non-existent user control caused my foo.aspx
to load instead of 404.
It could be a lot of things. I had this issue today because .NET had not been re-initialized after installing IIS (aspnet_regiis -i -enable
or equivalent).
Check that the anonymous user under which the site runs has read access to the file foo.aspx.
IIS6 and later uses a 404 response, thereby not letting an attacker know whether such a file even exists.