title: ObjectDisposedException in async ASP.NET Web API method with Autofac
body: <p>I am getting an ObjectDisposedException (Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed) during lazy instantiation of an object injected via Autofac in an async ASP.NET Web API method.</p>
  
  <p>This is the Web API method:</p>
  
  <pre><code>Lazy&lt;PrintHubSender&gt; _printHubSender;
  
  public async void Print(Guid orderId)
  {
      var order = await _orderNoSqlDbRepository.GetSingleAsync(o =&gt; o.Id == orderId);
      _printHubSender.Value.PrintOrder(order); // This triggers the exception
  }
  </code></pre>
  
  <p>The Lazy instance is injected via Web API controller constructor. The Autofac registration is as follows:</p>
  
  <pre><code>Type hubSender = ...
  containerBuilder.RegisterType(hubSender)
      .AsSelf()
      .PropertiesAutowired()
      .InstancePerRequest();
  </code></pre>
  
  <p>If the ASP.NET Web API method is not async the exception does not occur.</p>