您的位置:首页 > 其它

过滤器

2015-07-13 13:24 567 查看
[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("");
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: