Reputation: 2858
Suppose I have A CustomAuthorizeAttribute
and I thew Exception
in HandleUnauthorizedRequest
. Is there any way to catch that exception and format the message and display it to the user. If not than how should a thing like this be implemented.
Upvotes: 0
Views: 62
Reputation: 93424
Do you want to do this globally? Or on a per controller basis?
If Globally, then you can create your own HandleErrorAttribute which will catch any unhandled exceptions. You can then test if the exception is HandleUnauthorizedRequest or not.
If you want to do this on a per controller basis, then you can override OnException and handle it there.
Upvotes: 1