protected override bool AuthorizeCore(HttpContextBase httpContext) { if (httpContext == null) { throw new ArgumentNullException(nameof(httpContext)); } var user = httpContext.User; if (!user.Identity.IsAuthenticated) { return(false); } var userId = Convert.ToInt64(user.Identity.GetUserId()); var cookiePermission = HttpContext.Current.Request.Cookies.Get("ComisionPermission" + userId); if (cookiePermission != null) { var qbol2 = _accessControlService.HasPermission(cookiePermission["permissions"], RoleNameDefault); return(qbol2); } var xmlPermission = string.Join(",", _accessControlService.GetUserPermissions(userId).ToArray()); //XmlUtility.ConvertObjectToXml(_accessControl.GetUserPermissions(userId)); var myCookie = new HttpCookie("ComisionPermission" + userId) { ["permissions"] = xmlPermission, //["UserId"] = userId.ToString(), Expires = DateTime.Now.AddSeconds(30) }; HttpContext.Current.Response.Cookies.Add(myCookie); var qbol = _accessControlService.HasPermission(xmlPermission, RoleNameDefault); return(qbol); }