title: Can't retrieve UserId from Microsoft.AspNet.Identity
body: <p>I have created a new class that I want to manage a few things, one of which is to get the User Id <code>Microsoft.AspNet.Identity</code>. I get this error message</p>
  
  <blockquote>
    <p>CS0103    The name 'User' does not exist in the current context</p>
  </blockquote>
  
  <p>And this is my code:</p>
  
  <pre><code>using Microsoft.AspNet.Identity;
  
  public string UserId
  {
      get
      {
          return User.Identity.GetUserId();
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/s3wKK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s3wKK.png" alt="enter image description here"></a></p>
  
  <p>I was expecting intellisense to pick up the <code>Microsoft.AspNet.Identity</code> <code>GetUserId</code> method, but I get the error below.</p>
  
  <p>What am I doing wrong and why can't it pick up the <code>UserId</code> from <code>Microsoft.AspNet.Identity</code>.</p>