You have the option to inject Usermanager into your controller, and capture user information using _userManager.GetUserAsync(User);
and sending to your view on an object or filling your Viewmodel with that information and capturing in your View.
private UserManager<User> _userManager;
public SeuController(UserManager<User> userManager) {
_userManager = userManager;
}
public IActionResult Get() {
var user = await _userManager.GetUserAsync(User);
// user.NormalizedUserName <-- passe isso pra sua view
}
The other option is to inject the UserManager<User> userManager
with the @inject
right in the view.
@inject UserManager<User> userManager
<div>
@{
var user = await _userManager.GetUserAsync(User);
}
<span>
@user.NormalizedUserName
</span>
<div>
I would recommend using the first option in most cases.