I would like to raise a security exception whenever a user tries to access any area they're not entitled to. I need more control than the AuthorizeAttribute gives me so in the Action I have this: throw new HttpException((int)HttpStatusCode.Unauthorized, String.Empty);
which works fine for 404s and 403s. However what I get instead is a 500 error:
Description: An unhandled exception occurred during the
execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException:
Is there any way to throw a 401 or is it just a case of redirecting the user to a custom 401 view.