c# - ActionFilters not executing in expected order, possibly an autofac issue -


i have 2 action filters, need 1 explicitly execute before other. have not had luck getting them cooperate , execute in order expected.

public class redirectsingleattribute : actionfilterattrbute {    public urlhelper url { get; set; } // <= injected in onactivating    public override void onactionexecuted(actionexectuedcontext filtercontext) {        /* ... magic ... */    } }  public class jsonredirectattribute : actionfilterattribute {     public override void onactionexecuted(actionexecutedcontext filtercontext) {         /* ... magic ... */     } }  public class searchcontroller : controller {     [redirectsingle(order = 1)]     [jsonredirect(order = 2)]     public actionresult query(searchcriteria criteria) {         /* code */     } } 

my module looks like...

/* ... */ builder.registercontrollers(typeof(mvcapplication).assembly); /* ... */ builder.registertype<redirectsingleattribute>(); builder.registertype<jsonredirectattribute>()     .onactivating(c => c.instance.url = c.context.resolve<urlhelper>()); /* ... */ builder.registerfilterprovider(); 

i put breakpoint on both of onactionexecuted methods, , jsonredirectattribute consistently keeps executing first. tried reversing order, , tried using asactionfilterfor no success.

removing attributes action method, , using autofac registration style, attributes not execute @ all.

/* ended not working all, i.e. action filters never invoked */ builder.registertype<redirectsingleattribute>()     .asactionfilterfor<searchcontroller>(c => c.query(default(searchcriteria)), 1); builder.registertype<jsonredirectattribute>()     .onactivating(c => c.instance.url = c.context.resolve<urlhelper>())     .asactionfilterfor<searchcontroller>(c => c.query(default(searchcriteria)), 2); 

have tried setting "scope" enumeration value along "order" property. msdn link might throw light : https://msdn.microsoft.com/en-us/library/gg416513(vs.98).aspx

thanks.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -