Last post Jul 20, 2020 05:28 AM by itismesa
Jul 18, 2020 04:31 PM|itismesa|LINK
After I hosted a site in IIS, I am trying to get the current logged user but I keep getting
The command I am using is
I am not getting the user id of the domain user although it is working fine when I run it from inside visual studio.
In IIS I enabled windows authentication and disable all the rest.
Jul 18, 2020 06:24 PM|bruce (sqlwork.com)|LINK
You are getting the thread identity, which is the pool account. Use Context.User.Name to get the login user. Context can get injected if you need it in middleware.
Jul 19, 2020 03:15 AM|yogyogi|LINK
You can use the below code to get your username:
private UserManager<AppUser> userManager;
public AccountController(UserManager<AppUser> userMgr)
userManager = userMgr;
public async Task<IActionResult> Index()
AppUser user = await userManager.GetUserAsync(HttpContext.User);
string message = "Hello " + user.UserName;
More in at Showing Logged in User’s name
Jul 20, 2020 05:28 AM|itismesa|LINK
I got a quick way to do it