title: ASP.NET Core 3.1 "'User' does not contain a definition for 'FindFirstValue'"
body: <p>While trying to implement the answer from here > <a href="https://stackoverflow.com/questions/30701006/how-to-get-the-current-logged-in-user-id-in-asp-net-core/52135130?noredirect=1#comment108027391_52135130">How to get the current logged in user Id in ASP.NET Core</a>
  and the user redirected me to here > <a href="https://github.com/dotnet/aspnetcore/issues/18348" rel="nofollow noreferrer">https://github.com/dotnet/aspnetcore/issues/18348</a></p>
  
  <p><code>var UserId = User.FindFirstValue(ClaimTypes.Name);</code></p>
  
  <p>^ This is not working, and prints the following error <code>'User' does not contain a definition for 'FindFirstValue'</code></p>
  
  <p><strong>Edit: Adding controller snippet</strong></p>
  
  <p>The full snippet of my controller...</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  using Microsoft.AspNetCore.Http;
  using Microsoft.AspNetCore.Mvc;
  using Microsoft.Extensions.Logging;
  using ProjectName.Processing;
  using ProjectName.Repository;
  using Newtonsoft.Json;
  
  namespace ProjectName.Controllers
  {
      [ApiController]
      [Route("api/[controller]/[action]")]
      public class ClassNameController : ControllerBase
      {
          private readonly ILogger&lt;ClassNameController&gt; _logger;
          private OtherClassNameProcessing proc = new OtherClassNameProcessing();
  
          public ClassNameController(ILogger&lt;ClassNameController&gt; logger)
          {
              _logger = logger;
          }
  
          [HttpGet]
          [ProducesResponseType(typeof(List&lt;2ndOtherClassNameRepository&gt;), StatusCodes.Status200OK)]
          public IActionResult GetUserName()
          {
              var data = proc.GetUserName();
              return Ok(data.Result);
          }
      }
  }
  </code></pre>
  
  <p>The full snippet my controller is calling...</p>
  
  <pre><code>using Microsoft.EntityFrameworkCore;
  using ProjectName.Data;
  using ProjectName.Repo;
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  //using System.Web;
  using System.Threading.Tasks;
  using System.Security.Claims;
  using Microsoft.AspNetCore.Http;
  using System.Web.Providers.Entities;
  
  namespace ProjectName.Processing
  {
      public class OtherClassNameProcessing
      {
          private readonly ProjName_DevelContext _context = new ProjName_DevelContext();
          private async Task&lt;List&lt;2ndOtherClassNameRepository&gt;&gt; GetNameFromRepo()
          {
              List&lt;2ndOtherClassNameRepository&gt; repoList = new List&lt;2ndOtherClassNameRepository&gt;();
              var Temp = await _context.tablename.ToListAsync();
              /* Working Test
              2ndOtherClassNameRepository repo = new 2ndOtherClassNameRepository();
              repo.UserName = "JohnDoe";
              repoList.Add(repo);
              return repoList;
              */
              2ndOtherClassNameRepository repo = new 2ndOtherClassNameRepository();
              // repo.UserName = "JohnDoe";
              var userId = User.FindFirstValue(ClaimTypes.Name);
              repo.UserName = userId;
              repoList.Add(repo);
              return repoList;
          }
          internal async Task&lt;List&lt;2ndOtherClassNameRepository&gt;&gt; GetUserName()
          {
              return await GetNameFromRepo();
          }
      }
  }
  </code></pre>
  
  <p>Any idea why I'm getting this error?</p>