title: Unable to Inject IHttpContextAccessor
body: <p>Hello I am building a AspNetCore 2 WebApi application using angular 4 and JWT
  the broad definition of my issue is that I am unable to access <code>HttpContext.User</code> outside of my controllers.</p>
  
  <p>I am aware that this is by design and that .net gives us <code>IHttpContextAccessor</code> for this very reason. I am also aware that in R2 <code>IHttpContextAccessor</code> is no longer registered by default and that it should be registered as a singleton. here is a bit of my startup.cs</p>
  
  
  
  <pre class="lang-cs prettyprint-override"><code> 1.) services.AddSingleton&lt;IHttpContextAccessor, HttpContextAccessor&gt;();
   2.) services.AddSignalR();
   3.) services.AddTransient&lt;ClaimsPrincipal&gt;(s =&gt; s.GetService&lt;IHttpContextAccessor&gt;().HttpContext.User);
   4.) services.AddTransient&lt;UserResolverService&gt;();
  </code></pre>
  
  <p>As you can see I have tried a few things,
  for one i obviously am just adding an <code>IHttpContextAccessor</code> which I attempt to inject like this (which breaks, HttpContext is null)</p>
  
  <pre class="lang-cs prettyprint-override"><code>private readonly ClaimsPrincipal _caller;
  public ChatHub(IHttpContextAccessor accessor)
  {
     _caller = accessor.HttpContext.User;
  }
  </code></pre>
  
  <p>I have attempted putting this in a service and then injecting the service like this</p>
  
  <pre class="lang-cs prettyprint-override"><code>private string _userName;
  public ChatHub(UserResolverService userService)
  {
     _user = userService.GetUser();
  }
  </code></pre>
  
  <p>here is the service I mention (and also register as yo u can see above)</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class UserResolverService
  {
      private readonly IHttpContextAccessor _context;
  
      public UserResolverService(IHttpContextAccessor context)
      {
          _context = context;    
      }
  
      public string GetUser()
      {
          return _context.HttpContext.User.Identity.Name;
      }
  } 
  </code></pre>
  
  <p>this was just something I found here on stack overflow, seems to do nothing</p>
  
  <pre class="lang-cs prettyprint-override"><code>services.AddTransient&lt;ClaimsPrincipal&gt;(s =&gt; 
  s.GetService&lt;IHttpContextAccessor&gt;().HttpContext.User);
  </code></pre>
  
  <p>Im a little new to posting and I dont want to go off topic but in case it helps anyone really all I am trying to do is map users to connections in signalR, I have the chatSample from the github (<a href="https://github.com/aspnet/SignalR/tree/dev/samples/ChatSample" rel="nofollow noreferrer">https://github.com/aspnet/SignalR/tree/dev/samples/ChatSample</a>)
  working completely and perfectly in my app, aside from the fact that </p>
  
  <pre class="lang-cs prettyprint-override"><code>Context.User.Identity.Name
  </code></pre>
  
  <p>is null. and by context I am referring to</p>
  
  <pre class="lang-cs prettyprint-override"><code>HubCallerContext Hub.Context
  </code></pre>
  
  <p>however I dont imagine that the fact this is signalR is important. I should just be able to inject HttpContext and get the user info I need that way right?
  what am I missing? day 2 on this issue going nuts </p>