Skip to content

HttpFilters not being injected. #19

@iseesharp83

Description

@iseesharp83

In 3.2.4, the .BindHttpFilter<IFilter> method works fine, however the filter is never instantiated or injected.

Recreate:

  1. Create a Filter attribute (e.g. an action filter, as in the examples)
  2. 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 );
  3. Add breakpoints to the Filter's constructor or other methods
  4. Run the project
  5. 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:

  1. Recreate problem with 3.2.4 per steps above
  2. As the very first thing you bind (before binding filters), add this:
    container.Bind<HttpConfiguration>( ).ToMethod( ctx => GlobalConfiguration.Configuration );
  3. 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions