rest - I want a custom attribute to be fired automatically without writing that on the web api method -


i want custom attribute fired automatically without writing on web api method. way can achieve that?

let example have action filter attribute

public class myapiactionfilterattribute : filterattribute {     //... } 

with can assign class or action depending on how want used

public class myapicontroller : apicontroller {      [myapiactionfilter]     public ihttpactionresult myaction() {         return ok();     } } 

this applies action only.

but, if wanted applied on actions (globally) within web api, need add configuration.

globalconfiguration.configuration.filters.add(new myapiactionfilterattribute ()); 

this done @ startup web configuring web api.

note in doing above, filter applied requests.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -