asp.net core mvc ActionFilterAttribute 获取自动定义Attribute

 public class AgreeAuthorizeAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext context)
        {
        //转换ActionDescriptor 
        var controllerActionDescriptor = context.ActionDescriptor as ControllerActionDescriptor;

        var actionName = controllerActionDescriptor.ActionName;
        var controllerName = controllerActionDescriptor.ControllerName;

        var allowAgree = controllerActionDescriptor.MethodInfo
        .GetCustomAttributes(typeof(AnonymousAgreeAttribute), false).FirstOrDefault();
        }
    }

 

posted @ 2018-05-29 15:15  伏允坤  阅读(598)  评论(0编辑  收藏  举报