asp.net mvc 4 - ActionFilter is not executing in WebApplication but executing in WebApi -


i have created actionfilterattribute

public class loggingnhibernatesessionattribute : actionfilterattribute 

the purpose of filter name indicates logging , opens , commits transaction, before , after target action respectively.

i have webapi(myapi) project (mvc4) , webapplication(mycontent).

each api controller in myapi decorated attribute.

using myapp.web.common.filters;  namespace myapi.web.api.controllers {     [loggingnhibernatesession]     public class categoriescontroller : apicontroller     { 

when http action (get/post) executed inside apicontroller, actionfilter gets executed , works fine expected.

the problem: in webapplication(mycontent), have decorated controllers actionfilter.

using myapp.web.common.filters;  namespace mycontent.web.content.places.controllers {     [loggingnhibernatesession]     public class placescontroller : controller     { 

but here, when action executed inside controller, actionfilter not getting executed.

the actionfilter belongs system.web.http.filters;

i have read posts, , said use system.web.mvc filters. changed actionfilter system.web.mvc , when switched that, actionfilter stopped working in webapi well.

what doing wrong here?

although webapi , mvc similar , technically consist of largely same code, webapi created copying code rather through reuse. happened, i'm told, because wcf team didn't want dependency on mvc assemblies.

therefore, code (such custom filter) compiled against 1 assembly not work in context of other.

the solution duplicate own code , compile against both sets of assemblies. set build system cross-compile same code files using different reference assemblies.

it's sad when internal company politics result in this. least acknowledge problem , add proper cross-compile support tooling, alas, digress.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -