title: How to free resources and dispose injected service in ASP.NET 5/Core by the end of request?
body: <p>I have a service which is injected into a controller using the ASP.NET Core's default Dependency Injection Container:</p>
  
  <pre><code>public class FooBarService : IDisposable {
      public void Dispose() { ... }
  }
  
  services.AddScoped&lt;FooBarService&gt;();
  </code></pre>
  
  <p>This creates one instance per request. How to ensure that the framework would dispose the FooBarService instance by the end of each request, without relying on destructors and garbage collection?</p>