public override void OnAuthorization(AuthorizationContext filterContext) { if (Ignore) { return; } ; var userId = OperatorProvider.Instance.Current.UserId; var action = HttpContext.Current.Request.ServerVariables["SCRIPT_NAME"].ToString(); var title = string.Empty; bool hasPermission = PermissionService.ActionValidate(userId, action, out title); if (!hasPermission) { StringBuilder script = new StringBuilder(); script.Append("<script>alert('对不起,您没有权限访问当前页面。');</script>"); filterContext.Result = new ContentResult() { Content = script.ToString() }; } }