Action Filter not firing

Feb 19 at 11:56 PM

After installing SimpleInjector.Mvc nuget package, Action Filter like [Authorize] no longer fires. If I comment out the below line, action filter starts working.

//container.RegisterAttributeFilterProvider();

Is there any side effect of commenting out this line?
 
Coordinator
Feb 20 at 5:12 AM

Hi higish,

I incorrectly assumed that MVC would request an IFilterProvider from the dependency resolver, but it seems to get it directly from the static FilterProviders class. The RegisterAttributeFilterProvider method of the MVC NuGet package should have registered the SimpleInjectorFilterAttributeFilterProvider to the FilterProviders class.

What you can do to fix this is, go to the definition of the RegisterAttributeFilterProvider method and replace the following line:

container.RegisterSingle<IFilterProviderSimpleInjectorFilterAttributeFilterProvider>();

with the following:

FilterProviders.Providers.Add(new SimpleInjectorFilterAttributeFilterProvider(container));

I hope this helps.

Feb 20 at 6:07 AM

Thanks.

It is working now.

Coordinator
Feb 26 at 7:16 PM

A new version of the SimpleInjector.MVC3 NuGet package has been uploaded to NuGet. This package contains the fix and a few other minor changes. Please note that updating this package from the previous version will have no effect, since the NuGet package manager will not override an existing content file. If you are updating form a previous version of the SimpleInjector.MVC3 package, you will have to install it in a empty project and copy the SimpleInjectorMVC3Extensions.cs from the empty project to your real project.