protected override void HandleUnauthorizedRequest(AuthorizationContext context)
 {
     if (context.HttpContext.Request.IsAjaxRequest())
     {
         context.HttpContext.Response.StatusCode = 200;
         context.Result = new JsonResult
         {
             Data = new
             {
                 @ok   = false,
                 error = "抱歉,您没有权限操作此功能"
             },
             JsonRequestBehavior = JsonRequestBehavior.AllowGet
         };
     }
     else
     {
         base.HandleUnauthorizedRequest(context);
         if (AreaName.Equals("webadmin") && ControllerName.Equals("home") && ActionName.Equals("index"))
         {
             context.Result = new RedirectResult("/webadmin/home/login");
         }
         else
         {
             context.Result = new RedirectResult("/ErrorPage/401.html");
         }
     }
 }
        public ControllerActionDescriptor GetValue(IServiceProvider services)
        {
            if (_value != null)
            {
                return(_value);
            }

            var adcp    = services.GetRequiredService <IActionDescriptorCollectionProvider>();
            var actions = adcp.ActionDescriptors.Items;
            var action  = actions.OfType <ControllerActionDescriptor>()
                          .Where(s => s.ControllerName.Equals(_controller, StringComparison.OrdinalIgnoreCase))
                          .Where(s => s.ActionName.Equals(_action, StringComparison.OrdinalIgnoreCase))
                          .Where(s => s.RouteValues.TryGetValue("area", out var AreaName) && AreaName.Equals(_area, StringComparison.OrdinalIgnoreCase))
                          .Single();

            return(_value = action);
        }