I must have done something differently because someone would have raised a concern before this, but I could not get _httpContextAccessor.HttpContext.User?.Claims?.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value; in CurrentUserAccessor to return a value. In fact, User.Claims was always empty.
I fixed the problem by adding app.UseAuthentication(); above app.UseMvc(); in Startup.cs, but I thought I'd mention this in case I did something wrong. How are others getting the claims to appear without this line?
I must have done something differently because someone would have raised a concern before this, but I could not get
_httpContextAccessor.HttpContext.User?.Claims?.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value;
inCurrentUserAccessor
to return a value. In fact, User.Claims was always empty.I fixed the problem by adding
app.UseAuthentication();
aboveapp.UseMvc();
inStartup.cs
, but I thought I'd mention this in case I did something wrong. How are others getting the claims to appear without this line?