码迷,mamicode.com
首页 > 其他好文 > 详细

过滤器

时间:2015-07-13 14:00:27      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:

[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
public class RequireSslAttribute :FilterAttribute, IAuthorizationFilter 
{
public bool Require { get; set; }
public RequireSslAttribute()
{
Require = true; //???? TRUE

}
public void OnAuthorization(AuthorizationContext filterContext)
{
filterContext.Result = new RedirectResult("");
}
}

 

public class BlackList : AuthorizeAttribute
{
public void BlackList(bool isShow)
{


}

protected override bool AuthorizeCore(HttpContextBase httpContext)
{

return false;
}
protected virtual void HandleUnauthorizedRequest(AuthorizationContext filterContext) {

filterContext.Result = new RedirectResult("");
}
}

过滤器

标签:

原文地址:http://www.cnblogs.com/ok519/p/4642638.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!