4

In my web config I have this setting:

 <httpErrors errorMode="Custom" defaultPath="/Error/Error/ErrorHandler/404" defaultResponseMode="ExecuteURL" />

I would like to redirect all IIS errors to go to my own controller and action. However I get the error:

The requested page cannot be accessed because the related configuration data for the page is invalid.

However, If I try to redirect specific error codes to my controller, it will work. E.g:

<httpErrors errorMode="Custom" >
      <remove statusCode="403"/>
      <error statusCode="403" responseMode="ExecuteURL" path="/Error/Error/ErrorHandler/404"/>
    </httpErrors>

How can I change my default redirect to go to my controller/action?

Andrew Kilburn
  • 2,251
  • 6
  • 33
  • 65

1 Answers1

1

Looks like this is not possible. responseMode only supports:

  1. File for unprocessed files, like .html
  2. ExecuteURL supports .aspx files
  3. Redirect to redirect to a different page which is not recommended from a SEO perspective.

You could try the answer from mono blaine in this post: CustomErrors vs HttpErrors - A significant design flaw?

Jelle
  • 758
  • 2
  • 14
  • 36