I've struggled a couple of days with the error handling in MVC. I still do not have got it right. (I've also read most of the questions here at SO and googled until my fingers bled)
What I want to do:
- Use the standard
[Authorize]
attribute - Redirect all errors to my error controller (including unauthorized)
- Have one action per HTTP error in my error controller.
What I do not want to do:
- Put the
[ErrorHandler]
on all of my controllers (can it be used on my base controller)? - Use a custom Authorize attribute.
Actually I could do anything necessary (including the NOT list) as long as I get #1-3 working.
What I've tried:
- Using
Application_Error
- Using
Controller.HandleUnknownAction
- Using
Controller.OnException
- Using
[ErrorHandler]
on my controllers - Turning on/off
CustomErrors
in web.config
Guess I need a combination of those or maybe something else?