c# - ASP.NET Web API - ActionFilter Property not being set -
i have base controller class extends apicontroller , specifies abstract method:
[httppost] [validatemodelfilter(argument = "dto")] public abstract task<ihttpactionresult> post(postdto dto); this method implemented child classes, filter implictly applied without them realizing.
this approach works fine, filter executed. argument property not being set "dto".
this validatemodelfilter class:
public class validatemodelfilter : actionfilterattribute, iactionfilter, ifilter { public string argument { get; set; } public override void onactionexecuting(httpactioncontext actioncontext) { //some validation here... } } everything works fine except fact argument property null, whether apply filter this: [validatemodelfilter] or [validatemodelfilter(argument = "dto")]
please, note i'm using owin pipeline , ninject dependency injection.
for future readers, managed solve problem.
i registering filter in application's configuration:
public static void register(httpconfiguration configuration) { configuration.filters.add(new validatemodelfilter()); } this makes "global" , always executed, whether have filter annotation or not.
i commented line , filter works fine.
//configuation.filters.add(new validatemodelfilter());
Comments
Post a Comment