string userName = _httpContextAccessor.HttpContext.User.Identity.Name;
public string LoggedInUser => User.Identity.Name;
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
private readonly IHttpContextAccessor _httpContextAccessor;
//constructor then
_httpContextAccessor = httpContextAccessor;