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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -