IIS 7.0 404 Custom Error Page and web.config

Posted by Colin on Server Fault See other posts from Server Fault or by Colin
Published on 2011-05-06T00:04:17Z Indexed on 2012/07/11 9:17 UTC
Read the original article Hit count: 419

Filed under:
|
|
|

I am having trouble with a custom 404 error page.

I have a domain running a .NET proj with it's own error handling. I have a web.config running for the domain which contains:

<customErrors mode="RemoteOnly">
    <error statusCode="500" redirect="/Error"/>
    <error statusCode="404" redirect="/404"/>
</customErrors>

On a sub dir of that domain I am ignoring all routes there by doing routes.IgnoreRoute("Assets/{*pathInfo}"); in the .NET proj and I want to put a custom 404 error page on that and any sub dir's of Assets. The sub dir contains static content like images, css, js etc etc.

So in the Error Pages section of IIS I put a redirect to an absolute URL.

The web.config for that dir looks like the following:

<system.webServer>
    <httpErrors>
        <remove statusCode="404" subStatusCode="-1" />
        <error statusCode="404" prefixLanguageFilePath="" path="http://mydomain.com/404" responseMode="Redirect" />
    </httpErrors>
</system.webServer>

But I navigate to an unknown URL under that dir and yet I still see the default IIS 404 page.

I am also seeing an alert in IIS that reads:

You have configured detailed error messages to be returned for both local and remote requests. When this option is selected, custom error configuration is not used.

Does this have anything to do with the customErrors mode="RemoteOnly" in the site web.config?

I have tried to overwrite the customErrors in the sub dir web.config but nothing changes.

Any help would be appreciated.

Thanks.

© Server Fault or respective owner

Related posts about Windows

Related posts about iis7