Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Mar 02, 2010 04:30 PM|LINK
The best and safest thing for you to do would be to subclass AuthorizeAttribute and override only the HandleUnauthorizedRequest method. Then you could attribute your methods like so:
[MyCustomAuthorization(Roles = "some_role[, some_other_role[, ...]]")]
Don't override any other method as the default logic should suffice in your case. (The default logic handles things like the IsInRole() check, suppressing output caching, etc.) Then from the HandleUnauthorizedAttribute method, set filterContext.Result
= new RedirectResult("url_to_redirect_to").
Good luck. :)