public IHttpActionResult MyActionMethod() { var filters = ActionContext.ActionDescriptor.GetFilters(); // Filters contains the filters defined for MyActionMethod // Perform some action return Ok(); }
[Authorize] public IHttpActionResult MyActionMethod() { var filters = ActionContext.ActionDescriptor.GetFilters(); // Filters contains the authorization filter defined for MyActionMethod // Perform some action return Ok(); }This example shows how to use GetFilters to get the authorization filter defined for the action method. Package Library: The System.Web.Http package provides the HttpActionDescriptor class.