1

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.

Colin
  • 111
  • 1
  • 5

2 Answers2

1

You can try just add this :

<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/index.php" responseMode="ExecuteURL" />
</httpErrors>

In your "web.config" file.

0

This may be a little late, however you can put the following in the system.webserver part of the web.config

<system.webServer>
  <httpErrors existingResponse="PassThrough" />
</system.webServer>

Credit goes to this entry on Stack Overflow: https://stackoverflow.com/questions/434272/iis7-overrides-customerrors-when-setting-response-statuscode