mr100
mr100

Reputation: 4428

Umbraco application custom error redirect works for 500 status, but not for 404

In my umbraco application I have created error page and then defined in web.config custom error redirect to that page in case of failure like this:

<customErrors mode="RemoteOnly" defaultRedirect="~/Error" />

It works fine in case application returns status 500, but if user wants to access not existing page then redirect does not happen. I even try to specifically define redirect for 404 status like this:

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

but still without a success.

Upvotes: 1

Views: 553

Answers (1)

mr100
mr100

Reputation: 4428

The issue was in umbracoSettings.config. The default version of the file contained following rule definition:

<errors>
  <error404>1</error404>
</errors>

It seemingly has overridden the rule defined in web.config and in case of 404 status redirected to page with id "1". Removing the line with error404 everything works as expected:

<errors></errors>

Upvotes: 1

Related Questions