Net Core NLog.Web "aspnet-user-identity" is empty?

Accepted answer didn't worked for my case (using JwtSecurityToken on ASP.NET Core 3.1), Later realized that I just forgot to add the ClaimTypes.Name on my JwtSecurityToken Claims.

Now its working and no need to register IHttpContextAccessor.


I think I have found the issue,

There was an breaking change, The IHttpContextAccessor service is not registered by default anymore. (See announcement)

So add in your startup.cs:

public void ConfigureServices(IServiceCollection Services)
{
    //call this in case you need aspnet-user-authtype/aspnet-user-identity
    services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
}