title: How to pass custom argument to authorization policy
body: <p>I need a custom attribute for my rest API in asp.net core MVC. I want to add this attribute optionally to some of my APIs. This attribute checks if the API is accessible to user or not based on some condition and throws a 403 if it's not accessible. I was using filters to achieve this and the issue with filter is that filter code gets executed whether the attribute is added or not to my API.
  I would want that my filter code is executed only when this attribute is added to the API.<br>
  My colleague suggested that I should be using authorization policy instead of filters for this use case. Policies are executed only when it's added to the API. Also since I am throwing 403, authorization policy is a better candidate. I explored authorization policy but my issue is I am unable to pass custom attributes to Authorization policy.</p>
  
  <p>For example, I was able to do this using filters and custom attributes.</p>
  
  <pre><code>[MyCustomFeature("param1", "param2")]
  </code></pre>
  
  <p>How can I do the same in authorization policy? I am using this example for authorization policy.
  <a href="https://stackoverflow.com/questions/56369686/custom-authorization-attribute-asp-net-core/56369907?noredirect=1#comment99342362_56369907">Custom Authorization attribute asp.net core</a></p>