title: How to get HttpContext from Controller
body: <p>I'm using ASP.NET Core (MVC)</p>
  <p>If I call an endpoint, then <code>this.HttpContext</code> is not null.</p>
  <p>Within the same class as my endpoint, if I put a break point in the controller, <code>this.HttpContext</code> is always null.</p>
  <p>How do I get the value of <code>HttpContext</code> from the controller?</p>
  <pre><code>[Authorize]
  [ApiController]
  [Route(&quot;api/[controller]&quot;)]
  public class LoginController : ControllerBase
  {
      public LoginController()
      {
          var isNull = this.HttpContext; //always null
      }
  
      [HttpGet]
      public async Task Get()
      {
          var isNull = this.HttpContext; //not null
      }
  }
  </code></pre>
  <p>The purpose for this, is on each end point, I want to access some values (which are from a cookie). In NET Framework, I'd store the cookie values in a base class (from within the constructor).</p>
  <p>Whilst I can access HTTPContext on each each end point, doing it in the constructor means code it once per class.</p>
  <p>The goal is very much about coding this less. I'm hoping I'm not just being lazy</p>