Question

this is my first post on this great source of programming information.

I have developed new site for client and just doing some finishing touches.

I am trying to create custom error pages which would be read from web.config

 <system.web>
 <customErrors mode="RemoteOnly">
           <error statusCode="404" redirect="404.aspx" />
           <error statusCode="500" redirect="500.aspx" />
    </customErrors>

It works well on local development machine and 404 and 500 errors are shown as required.

After compilation and publishing site to web server it doesnt work. IIS 6 keeps on showing original IIS 6 error pages like this 404 error:

The page cannot be found

The page you are looking for might have been removed, 
had its name changed, or is temporarily unavailable. 
Please try the following:

Make sure that the Web site address displayed in the address bar of 
your browser is spelled and formatted correctly.

If you reached this page by clicking a link, contact the Web site 
administrator to alert them that the link is incorrectly formatted.

Click the Back button to try another link.
HTTP Error 404 - File or directory not found.
Internet Information Services (IIS)

I am not sure why is it doing this, I thought that web.config overwrites original IIS6 settings.


Ok I have found out that the problem is with the 404 .aspx page only. Error 500 is working fine and showing 500.aspx page. But not for 404.aspx. Please advice

Was it helpful?

Solution

The web config will only override IIS6 settings if the request is passed to the .NET ISAPI filter - for example, for pages ending with .aspx

If I browsed to a file or directory that didn't get to the .NET ISAPI it wouldn't use the web.config rules.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top