开发者

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
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜