title: Property Injection for Base Controller Class
body: <p>I'm trying to automatically set a property on any controller that derives from my <code>BaseController</code> class. Here is the code in my <code>Application_Start</code> method. The <code>UnitOfWork</code> property is always null when I try and access it.</p>
  
  <pre><code>var builder = new ContainerBuilder();
  builder.RegisterControllers(typeof(MvcApplication).Assembly);
  builder.RegisterType&lt;VesteraTechnologiesContext&gt;().As&lt;IContext&gt;();
  builder.RegisterType&lt;UnitOfWork&gt;().As&lt;IUnitOfWork&gt;();
  builder.RegisterType&lt;BaseController&gt;()
         .OnActivated(c =&gt; c.Instance.UnitOfWork = c.Context.Resolve&lt;IUnitOfWork&gt;());
  var container = builder.Build();
  DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
  </code></pre>
  
  <p>Here is what the BaseController looks like</p>
  
  <pre><code>public class BaseController : Controller
  {
      public IUnitOfWork UnitOfWork { get; set; }
  }
  </code></pre>
  
  <p>The reason I'm trying to do this via a property instead on through a constructor is so that I don't have to duplicate the constructor in every controller that needs access to the <code>UnitOfWork</code> property, since constructors are not inherited.</p>