过滤器
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("");
}
}
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("");
}
}
相关文章推荐
- Android中各单位转换
- CodeForces 197B Limit
- leetCode 51.N-Queens (n皇后问题) 解题思路和方法
- UML建模之用例图
- Ubuntu14.04下的grub小调整
- EXCEL 合并两列的内容
- JSON
- ffmpeg AVPacket & AVFrame
- 【To be continue】用过见过的芯片
- Linux学习笔记(13)——shell scripts
- poj3250 Bad Hair Day
- ListView滑动删除 ,仿腾讯QQ
- leetCode 50.Pow(x, n) (x的n次方) 解题思路和方法
- Spring学习笔记——为何使用Spring
- UNITY3D MAC版本号破解
- tomcat server.xml各个端口的作用
- LNTCM nginx-1.5+tomcat+mysql-5.6.16+couchbase-server_3.0实现web集群
- 花生壳如何搭建邮件服务器
- 月老的难题(二分图最大匹配之邻接链表篇)
- WebApi参数传递