Reputation: 21
How do I create my own authorize filter for the asp.net mvc controller?
I want to secure the controller actions that are releated to xo, what do I need to do for that?
Upvotes: 2
Views: 1661
Reputation: 12468
Simply extend AuthorizeAttribute and override AuthorizeCore, add in your own logic and return true or false.
public class CustomAuthorizeAttribute : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
var defaultResult = base.AuthorizeCore(httpContext);
// custom logic
return true; // or false
}
}
Upvotes: 1