过滤器

[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("");
}
}

posted @ 2015-07-13 13:24  汉城  阅读(156)  评论(0编辑  收藏  举报