Reputation: 2311
How can I intercept requests to a controller and check if the controller called has an [Authorize] attribute set? And if controller has it, How can override default implementation with my custom authentication routine?
thanks
Upvotes: 1
Views: 387
Reputation: 39501
public class MyAuthorizeAttribute : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
//your authorization logic here
}
}
And use [MyAuthorizeAttribute]
instead of [Authorize]
on your controllers or actions
Upvotes: 3