Web API ActionFilterAttribute可以访问模型吗?

Nul*_*nce 11 asp.net-mvc-4 asp.net-web-api

我希望能够在web api ActionFilter中进行一些权限检查,所以我需要能够提取对象ID.我可以在GET上执行此操作,因为我可以访问RouteData,但是可以在PUT\POST的动作过滤器中访问searlized viewModel对象吗?

 public override void OnActionExecuting(System.Web.Http.Controllers.HttpActionContext actionContext)
    {
        if (actionContext == null)
        {
            throw new ArgumentNullException("actionContext");
        }

       //Get ID from searlized object and check permissions for a POST\PUT? 
    }
Run Code Online (Sandbox Code Playgroud)

小智 13

你试过ActionArguments属性吗?

  • filterContext.ActionParameters (2认同)