asp.net mvc中权限判断失败时跳转页 ReturnUrl
2014-04-24 10:49
453 查看
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = true)] public class AdminAuthorizeAttribute : FilterAttribute, IAuthorizationFilter { private readonly bool _isLogin; public AdminAuthorizeAttribute(bool isLogin) { _isLogin = isLogin; } public void OnAuthorization(AuthorizationContext filterContext) { if (filterContext == null) throw new ArgumentNullException("filterContext"); if (OutputCacheAttribute.IsChildActionCacheActive(filterContext)) throw new InvalidOperationException( "You cannot use [MemberAuthorize] attribute when a child action cache is active"); if (_isLogin) { filterContext.Result = new HttpUnauthorizedResult(); } } }
红色地方标注的就是返回结果
该结果会在web.config中进行配置 都会加上ReturnUrl
<authentication mode="Forms"> <forms loginUrl="~/Test/Login" timeout="2880" /> </authentication>
配置后返回结果:/Test/Login?ReturnUrl=%2fTest%2fTestKindEditor
相关文章推荐
- C# MVC 用户登录状态判断 【C#】list 去重(转载) js 日期格式转换(转载) C#日期转换(转载) Nullable<System.DateTime>日期格式转换 (转载) Asp.Net MVC中Action跳转(转载)
- asp.net mvc的Filter来验证Forms 判断是否登录,角色权限以及错误处理(转)
- ASP.NET MVC使用ActionFilterAttribute实现权限限制的方法(附demo源码下载)
- ASP.NET MVC的跳转攻击问题
- Asp.net MVC权限设计思考 (一)数据库建库部分
- asp.net mvc razor布局页中a标签的href的跳转问题
- Asp.net Mvc 身份验证、异常处理、权限验证(拦截器)实现代码
- ASP.NET MVC +EasyUI 权限设计(四)角色动作
- ASP.NET MVC Authorization 自定义跳转
- asp.net mvc 中,抛弃membership结合自定义的权限表来使用[Authorize]
- 在ASP.NET MVC中实现基于URL的权限控制
- ASP.NET MVC 中login时为form 添加id、name以及returnurl
- ASP.NET MVC中权限控制的简单实现
- Asp.Net MVC中Action跳转小结
- ASP.NET MVC:窗体身份验证及角色权限管理示例
- ASP.NET MVC下判断用户登录和授权的方法
- asp.net mvc 全局权限过滤器及继成权限方法
- Asp.net MVC 基于规则的权限设计(续)-- 扩展微软企业库安全模块
- ASP.NET MVC +EasyUI 权限设计(二)环境搭建
- [整理]IIS 6.0 下部署 Asp.net MVC Web Api 后 HTTP PUT and DELETE 请求失败