title: What is the correct DefaultScopedLifestyle for an asp.net Core Web API service using Simple Injector?
body: <p>I'm trying to create a .net core WebApi service using Simple Injector. In my Startup.cs I have this:</p>
  
  <pre><code>public Startup(IHostingEnvironment env)
  {
      // Setup configuration stuff
      container = new Container();
      container.Options.DefaultScopedLifestyle = new AspNetRequestLifestyle();   // This is as specified in the docs.
  }
  
  public void ConfigureServices(IServiceCollection services)
  {
      // Add framework services.
      services.AddMvc();
      services.AddOptions();
      services.AddSingleton&lt;IControllerActivator&gt;(
          new SimpleInjectorControllerActivator(this.container));
  }
  
  public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  {
      app.UseSimpleInjectorAspNetRequestScoping(this.container);
  
      InitializeContainer(app);        // This registers stuff
  
      this.container.Verify();         // This blows up.
      app.UseMvc();
  }
  
  private void InitializeContainer(IApplicationBuilder app)
  {
      // Add application presentation components:
      this.container.RegisterMvcControllers(app);
      this.container.RegisterSingleton(new Log4NetAdapter(LogManager.GetLogger("Services.Api").Logger));
  
      // Register other stuff here.
  }
  </code></pre>
  
  <p>This compiles fine. But when I try to start the service I get the following error message on the <code>container.Verify()</code> step:</p>
  
  <blockquote>
    <p>{"The configuration is invalid. The following diagnostic warnings were reported:
        -[Disposable Transient Component] MessageController is registered as transient, but implements IDisposable.
        See the Error property for detailed information about the warnings. Please see <a href="https://simpleinjector.org/diagnostics" rel="nofollow noreferrer">https://simpleinjector.org/diagnostics</a> how to fix problems and how to suppress individual warnings."}</p>
    
    <p>-[Disposable Transient Component] MessageController is registered as transient, but implements IDisposable.
    The configuration is invalid. The following diagnostic warnings were reported:
    See the Error property for detailed information about the warnings. Please see <a href="https://simpleinjector.org/diagnostics" rel="nofollow noreferrer">https://simpleinjector.org/diagnostics</a> how to fix problems and how to suppress individual warnings.</p>
  </blockquote>
  
  <p>I tried including the necessary nuget package to use the <code>WebApiRequestLifestyle</code>, but it 
  appears that's only valid with standard .Net projects; not .net core.</p>
  
  <p>I found <a href="http://simpleinjector.readthedocs.io/en/latest/disposabletransientcomponent.html" rel="nofollow noreferrer">this page</a> in the docs. I'm able to run the service by ignoring the warning for my specific controllers:</p>
  
  <pre><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  {
      app.UseSimpleInjectorAspNetRequestScoping(this.container);
  
      InitializeContainer(app);        // This registers stuff
  
      var registration = container.GetRegistration(typeof(MessageController)).Registration;
  
      registration.SuppressDiagnosticWarning(DiagnosticType.DisposableTransientComponent, "This is a Web API controller. Disposal should be handled by the system.");
  
      this.container.Verify();         // Now this works
      app.UseMvc();
  }
  </code></pre>
  
  <p>The problem with that is that now I have to go in and suppress warnings for every additional controller. Shouldn't that be handled by the Default Lifestyle?</p>