title: Hook Unity into Web API Filter Attributes
body: <p>I have Unity running great for all the controllers in my ASP.NET Web API project - just using the default set up that comes out of the NuGet box. I have also managed to hook it up to MVC Filter Attributes - but can't seem to do the same for ASP.NET Web API filter attributes.</p>
  
  <p>How to I extend this default implementation to inject a dependency into an ActionFilterAttribute, for example...</p>
  
  <pre><code>public class BasicAuthenticationAttribute : ActionFilterAttribute
  {
      [Dependency]
      public IMyService myService { get; set; }
  
      public BasicAuthenticationAttribute()
      {
      }
  }
  </code></pre>
  
  <p>This filter is applied to controllers using attributes:</p>
  
  <pre><code>[BasicAuthentication]
  </code></pre>
  
  <p>I'm pretty sure I need to hook up the Unity container so it handles the creation of the attribute class, but need some clues about where to start as it does not use the same extensibility points as the MVC filters.</p>
  
  <p>I just wanted to add, other things I have tried include service location rather than dependency injection, but the DependencyResolver you get back is not the same one you configure.</p>
  
  <pre><code>// null
  var service = actionContext.Request.GetDependencyScope().GetService(typeof(IMyService));
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>// null
  var service = GlobalConfiguration.Configuration.DependencyResolver.GetService(typeof(IApiUserService));
  </code></pre>