标签:
CenterController:
/// <summary> /// 访问模块,写入系统菜单Id /// </summary> /// <param name="ModuleId"></param> /// <param name="ModuleName"></param> /// <returns></returns> public ActionResult SetModuleId(string ModuleId,string ModuleName) { string _ModuleId = DESEncrypt.Encrypt(ModuleId); CookieHelper.WriteCookie("ModuleId", _ModuleId); CookieHelper.WriteCookie("ThisModuleId", _ModuleId); var aa = CookieHelper.GetCookie("ModuleId"); if (!string.IsNullOrEmpty(ModuleName)) { Sys_SysLogBll.Instance.WriteLog(ModuleId, OperationType.Visit, "1", ModuleName); } return Content(_ModuleId); }
AuthorizationAttribute:
/// <summary> /// 执行权限认证 /// </summary> /// <returns></returns> private bool ActionAuthorize(AuthorizationContext filterContext) { if (ManageProvider.Provider.Current().IsSystem) return true; var areaName = filterContext.RouteData.DataTokens["area"] + "/"; //获取当前区域 var controllerName = filterContext.RouteData.Values["controller"] + "/"; //获取控制器 var action = filterContext.RouteData.Values["Action"]; //获取当前Action string requestPath = "/" + areaName + controllerName + action; //拼接构造完整url string ModuleId = DESEncrypt.Decrypt(CookieHelper.GetCookie("ThisModuleId")); bool Result = Sys_ModulePermissionBll.Instance.ActionAuthorize(requestPath.ToLower(), ManageProvider.Provider.Current().ObjectId, ModuleId, ManageProvider.Provider.Current().UserId); return Result; }
权限获取异常(不能用ModuleId,得换个名字)目前还没搞清楚为啥
标签:
原文地址:http://www.cnblogs.com/yechangzhong-826217795/p/5674770.html