How to retrieve all the filters that applies to one particular action in Web API


Sometimes you want to retrieve all the filters that one action supports, and you can do that via the following code snippet. Hope this helps.

Code Snippet
  1.          Collection<FilterInfo> filterInfoCollection = action.GetFilterPipeline(); // here action is action descriptor
  2.  
  3.          foreach (FilterInfo filterInfo in filterInfoCollection)
  4.          {
  5.              if (filterInfo.Instance is MyQueryableAttribute)
  6.              {
  7.                   supportQueryable = true;
  8.                   break;
  9.              }
  10.          }

Comments (0)