mvc登录授权特性
2016-01-14 11:53
423 查看
public class CommonAuthorize : AuthorizeAttribute { protected override bool AuthorizeCore(HttpContextBase httpContext) { return UserHelper.CurrentUser != null; } public override void OnAuthorization(AuthorizationContext filterContext) { if (!filterContext.ActionDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true) && !filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true)) { if (UserHelper.CurrentUser == null) { filterContext.Result = new RedirectResult(string.Format("/OAuth2/IndexUserInfo?returnUrl={0}", filterContext.HttpContext.Request.RawUrl)); } } } }
使用
[CommonAuthorize] public class BaseController : Controller {}
相关文章推荐
- iOS中json解析出现的null,nil,NSNumber的问题
- redhat gcc安装 libppl.so libppl_c.so等报错
- SharedPreferences——安卓存储方案之一
- APP分发渠道的竞争分析
- 获取IOS设备是Iphone几
- SPRING-SECURITY安全Web框架配置
- Android实现类似QQ的滑动删除效果
- 从网站中把数据都读到一个文本文件中。
- UIColor 类扩展支持十六进制
- 判断字符串是否全部是数字
- oracle的MAX_DUMP_FILE_SIZE参数和ora-02065
- 重回以前公司
- iframe超时处理。。。。
- ios开发小技巧
- hibernate的二级缓冲
- jsonp跨域解析
- Android.mk语法说明(android ndk开发)
- AOP基本概念
- js 数组排序
- const用法