asp.net mvc - WebApi Action filter called twice -


my webapi filter method onactionexecuted being called twice. filter (i make simple possible):

   public class nhibernateactionfilter : actionfilterattribute    {          //  [inject]         //   public isessionfactoryprovider sessionfactoryprovider { get; set; }         public override void onactionexecuted(httpactionexecutedcontext actionexecutedcontext)         {            var = 5;            var b = a;            //new basesessionprovider(sessionfactoryprovider).endcontextsession();         }     } 

my setup:

    protected void application_start()     {         arearegistration.registerallareas();         webapiconfig.register(globalconfiguration.configuration);         //http://stackoverflow.com/questions/9521040/how-to-add-global-asp-net-web-api-filters         filterconfig.registerwebapifilters(globalconfiguration.configuration.filters);     }      public class filterconfig     {          public static void registerwebapifilters(system.web.http.filters.httpfiltercollection filters)         {              filters.add(new nhibernateactionfilter());         }      } 

in debugger catch onactionexecuted twice same actionexecutedcontext. why?

upd

controller public class banksmscontroller : apicontroller {          [acceptverbs(httpverbs.get)]          public int gettest()          {              return 1;          } } 

i have suspicion, strange behavior can fixed either overriding allowmultiple property of filter , returning false, or applying attributeusage attribute allowmultiple set false (this influences on default implementation of allowmultiple property of filter.

at least in our project helped (we have filters injected via autofac).


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -