title: Property injection in to Web Api controller using Autofac
body: <p>I'm trying to set a property on an <code>System.Web.Http.ApiController</code> to a value of a resolved <code>IServerPackageRepository</code>. The controller runs in a <code>HttpSelfHostServer</code> and the <code>DependencyResolver</code> has been set to <code>AutofacWebApiDependencyResolver</code>. Here is the code from the <code>Autofac.Module.Load</code> method</p>
  
  <pre><code>...
  
  builder.RegisterType&lt;ServerPackageRepository&gt;()
      .As&lt;IServerPackageRepository&gt;()
      .SingleInstance()
      .WithParameter("path", this.StoragePath);
  
  builder.RegisterApiControllers(Assembly.GetExecutingAssembly())
      .PropertiesAutowired();
  </code></pre>
  
  <p>The <code>ApiController</code> controller itself has a property of type</p>
  
  <pre><code>public IServerPackageRepository Repository { get; set; }
  </code></pre>
  
  <p>but is never resolved.</p>
  
  <p>I am trying to do it this way because <code>ApiController</code> won't take nothing but default constructors. Any suggestions on how to do this the correct way using Autofac?</p>