title: ASP.NET Core 2.0 inject Controller with Autofac
body: <p>I'm trying to inject my controller with Autofac. Unfortunately I am unable to configure Autofac in away so that the 'DefaultControllerActivator` wont construct my controllers? </p>
  
  <pre><code>    public IServiceProvider ConfigureServices(IServiceCollection services)
      {
          services.AddMvc().AddControllersAsServices();
          var containerBuilder = new ContainerBuilder();
          containerBuilder.RegisterModule&lt;ServiceModule&gt;();
          containerBuilder.Populate(services);
          containerBuilder.RegisterType&lt;LoginController&gt;().PropertiesAutowired();
  
          ApplicationContainer = containerBuilder.Build();
          return new AutofacServiceProvider(this.ApplicationContainer);
      }
  
      public class ServiceModule : Module
      {
          protected override void Load(ContainerBuilder builder)
          {
              builder.RegisterModule(new DataProviderModule());
              builder.RegisterType(typeof(LoginService)).As(typeof(ILoginService)).InstancePerRequest();
          }
      }
  
      [Route("api/[controller]")]
      public class LoginController : Controller
      {
          private readonly ILoginService _loginService;
  
          public LoginController(ILoginService loginService)
          {
              _loginService = loginService;
          }
      }
  </code></pre>
  
  <p>I followed the documentation of Autofac as shown above. Unfortunately the LoginController will not be constructed because it requires an injection.</p>
  
  <p>edit: If there is a way of using "Modules" without Autofac, I'd be very interesting for any suggestions :)</p>
  
  <p>Thanks you in advance!</p>