Property Injection & Action Filters in EPiServer 7 CMS

I spent a bit of time putting in some custom implementation to support Property Injection on to my Action Filters before realizing that EPiServer 7 already provides this functionality for me. Doh.

In order to take advantage all you need to do is set your DI controlled interface to the generic type property of the Injected class. This will lazily set the interface when the property is used…awesome.

public class CustomFilter : ActionFilterAttribute
{
public Injected Service { get; set; }
}