title: HttpContext.RequestServices.GetService<T>() vs services.AddScope<T>()?
body: <p>In the following code (from <a href="https://github.com/JasonGT/NorthwindTraders/blob/master/Src/WebUI/Controllers/BaseController.cs" rel="noreferrer">https://github.com/JasonGT/NorthwindTraders/blob/master/Src/WebUI/Controllers/BaseController.cs</a>), it's a base control inherited by all controllers.</p>
  
  <pre><code>[ApiController]
  [Route("api/[controller]/[action]")]
  public abstract class BaseController : ControllerBase
  {
      private IMediator _mediator;
  
      protected IMediator Mediator =&gt; _mediator ??= HttpContext.RequestServices.GetService&lt;IMediator&gt;();
  }
  </code></pre>
  
  <p>The sub-class controllers then just use the property of <code>Mediator</code>.</p>
  
  <p>How it differs from just adding <code>services.AddScope&lt;Mediator&gt;();</code> in <code>Startup.cs</code> and then inject <code>mediator</code>.</p>
  
  <pre><code>// Startup.cs
  public void ConfigureServices(IServiceCollection services)
  {
      // services.AddSingleton&lt;Mediator&gt;(); 
      services.AddScope&lt;Mediator&gt;();
  </code></pre>