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
Post a Comment