title: How to integrate Autofac with WepApi 2 and Owin?
body: <p>I am using this package to integrate Autofac with my WebApi Owin application:</p>
  
  <p><a href="https://www.nuget.org/packages/Autofac.WebApi2.Owin">https://www.nuget.org/packages/Autofac.WebApi2.Owin</a></p>
  
  <p>And following this post:</p>
  
  <p><a href="http://alexmg.com/owin-support-for-the-web-api-2-and-mvc-5-integrations-in-autofac/">http://alexmg.com/owin-support-for-the-web-api-2-and-mvc-5-integrations-in-autofac/</a></p>
  
  <p>My code in Startup.cs looks like this:</p>
  
  <pre><code>        var config = new HttpConfiguration();
  
          IContainer container = EngineContext.InitializeEngine();
  
          var dependencyResolver = new AutofacWebApiDependencyResolver(container);
          config.DependencyResolver = dependencyResolver;
  
          app.UseAutofacMiddleware(container);
          app.UseAutofacWebApi(config);
  
          WebApiConfig.Register(config);
          app.UseWebApi(config);
  </code></pre>
  
  <p>However whichever way I spin it, rearrange the code or whatever, Autofac is just not able to resolve anything. Before Owin I had my Global.asax method working just fine:</p>
  
  <pre><code>    protected void Application_Start()
      {
          IContainer container = EngineContext.InitializeEngine();
  
          var dependencyResolver = new AutofacWebApiDependencyResolver(container);
          GlobalConfiguration.Configuration.DependencyResolver = dependencyResolver;
  
          GlobalConfiguration.Configure(WebApiConfig.Register);
      }
  </code></pre>
  
  <p>What am I missing?</p>
  
  <p>Thanks</p>