forked from remogloor/Ninject.Web.WebApi
-
Notifications
You must be signed in to change notification settings - Fork 36
Closed
Description
In 3.2.4, the .BindHttpFilter<IFilter> method works fine, however the filter is never instantiated or injected.
Recreate:
- Create a Filter attribute (e.g. an action filter, as in the examples)
- In a NinjectConfigurator (or wherever your configurations are done), bind the filter w/ the syntax, putting it in whatever scope you'd like:
container.BindHttpFilter<LogActionFilter>( FilterScope.Controller ); - Add breakpoints to the Filter's constructor or other methods
- Run the project
- Hit a controller (e.g. "api/customers"). Notice that the constructor is never called.
Downgrade to 3.2.2, repeat steps above, notice constructor is called.
I ran a diff between 3.2.2 and 3.2.4, and apparently the offending line is this one:
this.Bind<HttpConfiguration>( ).ToMethod( ctx => GlobalConfiguration.Configuration );
Proof:
- Recreate problem with 3.2.4 per steps above
- As the very first thing you bind (before binding filters), add this:
container.Bind<HttpConfiguration>( ).ToMethod( ctx => GlobalConfiguration.Configuration ); - Repeat steps, notice constructor is now called.
Not sure why the bind to HttpConfiguration was removed, but it apparently broke HttpFilter injection.
Metadata
Metadata
Assignees
Labels
No labels