title: Autofac with MVC4: controller does not have a default constructor
body: <p>I've been working with Autofac in MVC3 and love it. Now I am trying to implement it with MVC4. </p>
  
  <p>I installed the pre-release versions of Autofac MVC4 and Autofac WebApi through the Package Manager Console (Install-Package Autofac.Mvc4 -Pre and Install-Package Autofac.WebApi -Pre)</p>
  
  <p>I adjusted my IoC container as following:</p>
  
  <pre><code>    private static void SetAutofacContainer()
      {
          var builder = new ContainerBuilder();
  
          builder.RegisterControllers(Assembly.GetExecutingAssembly());
          builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
  
          builder.RegisterType&lt;UnitOfWork&gt;().As&lt;IUnitOfWork&gt;().InstancePerHttpRequest().InstancePerApiRequest();
          builder.RegisterType&lt;DatabaseFactory&gt;().As&lt;IDatabaseFactory&gt;().InstancePerHttpRequest().InstancePerApiRequest();
          builder.RegisterType&lt;RepositoryWrapper&gt;().As&lt;RepositoryWrapper&gt;().InstancePerHttpRequest().InstancePerApiRequest();
          builder.RegisterType&lt;ServiceWrapper&gt;().As&lt;ServiceWrapper&gt;().InstancePerHttpRequest().InstancePerApiRequest();
  
          // Repositories
          builder.RegisterAssemblyTypes(typeof(UserRepository).Assembly).Where(t =&gt; t.Name.EndsWith("Repository")).AsImplementedInterfaces().InstancePerHttpRequest().InstancePerApiRequest();
  
          // Services
          builder.RegisterAssemblyTypes(typeof(UserService).Assembly).Where(t =&gt; t.Name.EndsWith("Service")).AsImplementedInterfaces().InstancePerHttpRequest().InstancePerApiRequest();
  
          IContainer container = builder.Build();
          DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
          GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);
  
      }
  </code></pre>
  
  <p>When I run the application (by accessing the API controller) I get the exception:
  "<strong>Controllers.UserController' does not have a default constructor</strong>"</p>
  
  <p>The controller looks like this:</p>
  
  <pre><code>namespace Controllers
  {
  [Authorize]
  public class UserController : ApiController
  {
      private ServiceWrapper _services;
  
      public UserController(ServiceWrapper services)
      {
          _services = services;
      }
  
      // GET api/user/{userrequest}
      public IQueryable&lt;User&gt; Get(UserRequest request)
      {
          if (ModelState.IsValid)
          {
            '...
          }  
      } 
  }
  </code></pre>
  
  <p>Am I missing something? Did I not set it up right? Any help would be greatly appreciated! </p>
  
  <p><strong>Update</strong></p>
  
  <p>My API controller are within a separate project in the same solution. If I place the API controller in my main MVC project, it works. Could someone please enlighten me on how to get Autofac to register the API controllers in my API project?</p>