I have written a custom web page, to deal with a 404 page not found error. Control is redirected to my custom web page by the custom errors tag in my web.config file.
<authentication mode="Windows"/>
<customErrors mode="On" defaultRedirect="PageNotFoundGateWay.aspx">
<error statusCode="404" redirect="PageNotFoundGateWay.aspx"/>
</customErrors>
This works fine if someone tries to access a .aspx file that does not exists. But if someone tries to access any other type of web page, or no web page at all then control is never redirected to my custome web page (PageNotFoundGateWay.aspx). Does anyone know why the redirect works if someone types in the name of an .aspx file that does not exists? But yet does not work for other types of web pages. Or if just a directory is typed in the URL.
Here is an example of what I am talking about.
If the following URL is typed in the command line and myPage.aspx does not exists, then program execution is redirected to my page PageNotFoundGateWay.aspx.
http://www.mysite.com/thefolder/myPage.aspx
Yet if any of the following URL's are accessed then I get the default .NET file not found web page.
http://www.mysite.com/thefolder/myStarPage.html // Note myStarPage.html does not exists. I only get the .NET default file not found web page and not my custom web page. It does not like the .html filename exstension.
http//www.mysite.com/thefolder/fakefolder // No file name is specified at all. I only get the .NET default file not found web page and not my custom web page.