Error!
Success!

Dependency Injection for Filters with Ninject in MVC3 - Using Filter A

0
kicks

Dependency Injection for Filters with Ninject in MVC3 - Using Filter A  (Unpublished)

This is my part two series of implementing dependency injection for filters in MVC3 with Ninject. In this post, we will see that we can also implement dependency injection with Filter Attributes. The steps to do this are almost similar to the steps to implement using the 'BindFilter' method (described on my previous post referred above). Except now a new attribute class that derived from 'FilterAttribute' needs to be created. Then we need to modify our filter binding in the 'RegisterServices' method to use extension methods such as 'WhenActionHas', 'WhenControllerHas' or 'WhenActionMethodHas' to refer to the attribute class. After that, the filter can be applied to a specific action or controller by putting '[filterattribute]' notation.


Kicked By:
Drop Kicked By: