title: I'm having sudden unauthorized/internal server errors
body: <p>I'm creating this webpage in Angular with .NET as my backend. Everything was working just fine, but today (all of a sudden) I'm getting Unauthorized errors (401). When I remove my authorization, I'm getting internal server errors (meaning my 'User.Identity.Name') does not work. So I'm guessing there is a problem with my JWT</p>
  
  <p>I have tried to remove authorization headers. But that gave me an internal server error (500). The only requests that work are those not using IdentityUser and thus being [AllowAnonymous]</p>
  
  <p>I have no idea what the problem could be, so it's hard to show some code. But since I think the problem has something to do with my JWT I'll add some code of that.</p>
  
  <pre class="lang-js prettyprint-override"><code>    [Route("api/[controller]")]
          [ApiController]
          [Produces("application/json")]
          [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
          public class BierenController : ControllerBase
          {
              private readonly IBierRepository _bierRepository;
              private readonly IGebruikerRepository _gebruikerRepository;
              private readonly IBrouwerRepository _brouwerRepository;
  
              public BierenController(IBierRepository bierRepository, IGebruikerRepository gebruikerRepository, IBrouwerRepository brouwerRepository)
              {
                  _bierRepository = bierRepository;
                  _gebruikerRepository = gebruikerRepository;
                  _brouwerRepository = brouwerRepository;
              }
  
  
              [HttpGet]
              [AllowAnonymous]
              public IEnumerable&lt;Bier&gt; GetBieren()
              {
                  return _bierRepository.GetAll().OrderBy(b =&gt; b.Naam);
              }
  
              [HttpGet("{id}")]
              [AllowAnonymous]
              public ActionResult&lt;Bier&gt; GetBier(int id)
              {
                  Bier bier = _bierRepository.GetBy(id);
                  if (bier == null)
                      return NotFound();
                  return bier;
              }
  
              [HttpPost]
              [Authorize(Roles = "Brouwer, Admin")]
              public IActionResult PostBier(Bier bier)
              {
                  Brouwer brouwer = _brouwerRepository.GetBy(User.Identity.Name);
                  brouwer.AddBier(bier);
                  _brouwerRepository.SaveChanges();
                  return NoContent();
              }
  </code></pre>
  
  <p>Any help is appreciated, if anyone could help, seeing some extra code I'm happy to provide it.
  <a href="https://i.stack.imgur.com/5ZtNn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5ZtNn.png" alt="Screenshot of error"></a></p>