title: HttpContext null in constructor
body: <p>I have a UserContext Service where I'll put some basic functionalities ("<code>IsAuthenticated</code>, <code>GetUser</code> etc...)</p>
  
  <p>In order to do that, I need to pass the <code>HTTPContext</code> from my WebAPI Controller to my Class Library Service.</p>
  
  <p>Actually, <code>HttpContext</code> is always <code>null</code> in the web api controller.</p>
  
  <p>Anybody have a solution to resolve my issue ?.
  Is there a better way to acheive it.</p>
  
  <p><strong>Web API User Controller</strong></p>
  
  <pre><code>[Route("api/[controller]")]
  [Authorize]
  public class UserController : Controller
  {
      private readonly IUserContextServices _userContextServices;
      private readonly User loggedUser;
  
      public UserController()
      {
         //HttpContext ALWAYS NULL
          _userContextServices = new UserContextService(HttpContext);
      }
   }  
  </code></pre>
  
  <p><strong>UserContext Services</strong></p>
  
  <pre><code>namespace MyProj.Services
  {
      public interface IUserContextServices
      {
          UserContext GetUserContext();
          bool IsUserAuthenticated();
      }
  
      public class UserContextService : IUserContextServices
      {
          private readonly HttpContext _context;
          private UserContext _userContext;
          public UserContextService(HttpContext context)
          {
              _context = context;
              InitUserContext();
          }
  
          private IEnumerable&lt;Claim&gt; GetUserClaims()
          {
              if (IsUserAuthenticated())
              {
                  return _context.User.Claims;
              }
              return null;
          }
  
          private void InitUserContext()
          {
              if (IsUserAuthenticated())
              {
                  var claims = GetUserClaims();
                  _userContext = new UserContext();
                  _userContext.Email = claims.First(p =&gt; p.Type == "email").Value;
                  _userContext.AspNetUserID = claims.First(p =&gt; p.Type == "sub").Value;
              }
          }
  
          public UserContext GetUserContext()
          {
              return _userContext;
          }
  
          public bool IsUserAuthenticated()
          {
              return _context.User != null &amp;&amp; _context.User.Identity != null &amp;&amp; _context.User.Identity.IsAuthenticated;
          }
      }
  }
  </code></pre>