Как получить пользователь показать MVC Controller Core 3.1
string userName = _httpContextAccessor.HttpContext.User.Identity.Name;
Expensive Echidna
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;