using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PaiXie.Core;
using Newtonsoft.Json;
using PaiXie.Utils;
using PaiXie.Bll;
namespace PaiXie.Pos.Admin {
/// <summary>
/// 权限控制
/// </summary>
public class MvcMenuFilter : ActionFilterAttribute { #region 权限控制 private bool _isEnable = true; public MvcMenuFilter() {
_isEnable = true;
} public MvcMenuFilter(bool IsEnable) {
_isEnable = IsEnable;
} public override void OnActionExecuting(ActionExecutingContext filterContext) { try {
//默认true 执行验证
if (_isEnable) {
var route = filterContext.RouteData.Values;
string area = filterContext.RouteData.DataTokens["area"].ToString();
var url = string.Format("/{0}/{1}/{2}", area, route["controller"], route["action"]);
//没有权限
if (!new Users().IsAuth(url)) {
//if (_isEnable) {
BaseResult BaseResult = new BaseResult();
BaseResult.result = -99;
BaseResult.message = "没有权限!";
string str = JsonConvert.SerializeObject(BaseResult, Formatting.Indented);
ContentResult ContentResult = new ContentResult();
ContentResult.Content = str;
filterContext.Result = ContentResult;
//}
}
}
}
catch (Exception ex) { PlanLog.WriteLog(ex.ToString(), "MvcMenuFilter"); }
base.OnActionExecuting(filterContext);
}
#endregion
}
}

  

最新文章

  1. C++: DataGridView::DataSource
  2. Java 8 Lambda表达式探险
  3. CobarClient源码分析(1)
  4. 查看SqlServer的内存使用情况
  5. nyoj 119 士兵杀敌(三)(RMQ)
  6. .NET 进程和线程
  7. [翻译][MVC 5 + EF 6] 7:加载相关数据
  8. Python队列服务 Python RQ Functions from the __main__ module cannot be processed by workers.
  9. HTML基础(2) 格式标签 文本标签
  10. calling c++ from golang with swig--windows dll(一)
  11. LinkedHashMap:我还能实现LRU
  12. 对象序列化 输入输出流概念 InputOutStream OutputStream
  13. [BZOJ1031] [JSOI2007] 字符加密Cipher (后缀数组)
  14. 学习ASP.NET Core Razor 编程系列二——添加一个实体
  15. ES6常用特性总览
  16. .NET Core中延迟单例另一种写法【.NET Core和.NET Framework的beforefieldinit差异】
  17. layui前端框架
  18. 菜鸟入门【ASP.NET Core】9:RoutingMiddleware介绍以及MVC引入
  19. .NET拾忆:EventLog(Windows事件日志监控)
  20. 微擎 人人商城 merchant.php源码

热门文章

  1. UiTextField 限制输入长度
  2. 牛客网-《剑指offer》-跳台阶
  3. 微信小程序 - 动态背景图片实现
  4. C++ 第六课:C/C++关键字及其用法
  5. 算法笔记_229:有理数的循环节(Java)
  6. selenium快速跳转视图到指定元素
  7. MySQL事物系列:3:innodb_flush_log_at_trx_commit小实验
  8. 使用 loop device 制作安装镜像
  9. Android——碎片事务调用失败
  10. Multitenant Architecture---PDB与CDB