public bool ValiddatePermission(AccountModel account, string controller, string action, string actionPath, string filePath) { bool bResult = false; string actionName = ValidateHelper.IsNullOrEmpty(ActionName) ? action : ActionName; if (account != null) { IList <permModel> perm = null; //测试当前controller是否已赋权限值,如果没有从 //如果存在区域,Seesion保存(区域+控制器) if (!ValidateHelper.IsNullOrEmpty(Area)) { controller = Area + "/" + controller; } perm = (List <permModel>)HttpContext.Current.Session[account.UserCode + ":" + filePath]; if (perm == null) { SysRightApp _appRole = new SysRightApp(); perm = _appRole.GetPermission(account.UserCode, filePath); //获取当前用户的权限列表 HttpContext.Current.Session[account.UserCode + ":" + filePath] = perm; //获取的劝降放入会话由Controller调用 } //当用户访问index时,只要权限>0就可以访问 if (actionName.ToLower() == "index") { if (perm.Count > 0) { return(true); } } //查询当前Action 是否有操作权限,大于0表示有,否则没有 int count = perm.Where(a => a.KEYCODE.ToLower() == actionName.ToLower()).Count(); if (count > 0) { bResult = true; } else { bResult = false; } } return(bResult); }