I turned on global error handling for the application by applying the HandleError attribute in the filterConfig registration.
public class FilterConfig { public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new HandleErrorAttribute()); } }
Then I use custom errors (web.config) to hopefully display a friendly error message for every server error.
<customErrors mode="On" ></customErrors>
It seemed to work fine for most exceptions, and I was getting the expected behavior in displaying a custom page with a View error (Error.cshtml in the general view folder).
However, I recently noticed that this is not the behavior that I see if the error was selected as UnauthorizedAccessException.
I am a bit stumped with this, as I look at the scratch, I see that this UnauthorizedAccessException returns a normal internal server 500 error, as does the standard exception.
So why is the standard exception thrown by my customError setting, but the UnauthorizedAccessException does not work?
ANd, how can I make them behave the same way, since they are essentially a mistake that I want to prevent the end user from seeing.
source share