In my ASP.Net MVC application I have implemented a Custom ActionFilter to Authorize users.
I use CastleWindsor to provide dependency injection into all of the controllers as follows:
protected virtual IWindsorContainer InitializeServiceLocator()
{
IWindsorContainer container = new WindsorContainer();
ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container));
container.RegisterControllers(typeof(HomeController).Assembly);
ComponentRegistrar.AddComponentsTo(container);
ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(container));
return container;
}
Within my CustomAttribute, I need a dependency that is used by all of my controllers, however I am unable to user Constructor based injection in an attribute.
So what's the cleanest way out here? How can I provide the dependency?
IFilterProvider
)). – Freckle