In ASP.NET MVC, I would like to somehow do custom authorization using the MvcSiteMapProvider.
I am aware I can implement a custom Authorization Attribute that inherits from AuthorizeAttribute. Then, we can perhaps decorate out controllers with [SiteMapAuthorize] for instance.
Is this the best route? If so, what I am looking for is the proper implementation of using a site map provider with authorize.
public class SiteMapAuthorizeAttribute : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
}
}
Thanks for any help!
I’ve got this working
Here is my solution:
The HandleUnauthorizedRequest works with the customErrors section in the web.config:
You will need an Errors Controller for the above customErrors to work:
How to use CustomErrors in ASP.NET MVC 2