How to create the custom authorize filter?
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开发者_StackOverflow社区 for that?
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
}
}
精彩评论