title: Get logged in UserId in Blazor 6 Wasm controller
body: <p>I have a Blazor Wasm app under .Net 6 (upgraded from .Net Core). I added default Identity from the Blazor Train video with Chris Sainty which now appears to work. I didn't want to use the Blazor 6 template &amp; Duende.</p>
  <p>But I can't get the UserId (not the email) within a controller.</p>
  <p>There are several Stack Overflow questions about this but not a clear answer for Blazor 6.<br />
  In the controller, once logged in:</p>
  <pre><code>User.FindFirstValue(ClaimTypes.NameIdentifier)  
  </code></pre>
  <p>returns null, also adding a test component to display the user Id also shows null for the user Id</p>
  <pre><code>if (user.Identity.IsAuthenticated)
      {
          _authMessage = $&quot;{user.Identity.Name} is authenticated.&quot;;
          _claims = user.Claims;
          _userId = $&quot;User Id: {user.FindFirst(c =&gt; c.Type == &quot;sub&quot;)?.Value}&quot;;
      }
  </code></pre>
  <p>I see various statements about HttpContext not being available in Wasm controller, and userManager also not being available.  I've tried both with the same result.</p>
  <p>Any guidance?</p>