Dependency Injection for Filters with Ninject in MVC3 - Using Filter A(rical.blogspot.com)
submitted by
rical(26) 7 months, 16 days ago
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.
|category: MVC
|Views: 13
tags:
MVC another
Everyones tags:
Your Tags: