title: Principal.Identity.Name in Task ran from Controller Action
body: <p>In a controller action I'm running</p>
  
  <pre><code>public ActionResult MyAction()
  {
      Task.Factory.StartNew( () =&gt;
      {
          myService.ExecuteMethod( someArgs );
      } );
  }
  </code></pre>
  
  <p>The service will call other class methods that call others, and somewhere down the line, an <code>IPrincipal</code> is injected into the constructor of a class.</p>
  
  <p>The <code>IPrincipal</code> is created by doing <code>HttpContext.Current.User</code>.</p>
  
  <p>Since the code is in a <code>Task</code>, it runs on a different thread, and the action has returned so <code>HttpContext.Current</code> is <code>null</code>.</p>
  
  <p>If I try doing <code>Thread.CurrentPrincipal</code>, it exists, but is set to something other than what the <code>HttpContext.Current.User</code> was. Also, if I try accessing <code>Thread.CurrentPrincipal.Identity.Name</code>, I get an <code>ObjectDisposedException</code> thrown.</p>
  
  <p>I'm using Ninject for my IoC container. The <code>IPrincipal</code> binding looks like this</p>
  
  <pre><code>Bind&lt;IPrincipal&gt;().ToMethod( x =&gt; HttpContext.Current.User );
  </code></pre>
  
  <p>Is there a way to get the correct or even a usable <code>IPrincipal</code> in the code ran from a <code>Task</code> in a controller action?</p>