I dont know how can I get the login user details in my controller. from Google I applied the following code but the error is coming as given below
InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UserManager`1[MetaWeather.Models.ApplicationUser]' while attempting to activate 'MetaWeather.Areas.Customer.Controllers.ForcastController'.
[Area("Customer")]
[Authorize]
public class ForcastController : Controller
{
private readonly IWeatherRepository _weatherRepository;
private readonly IUnitOfWork _unitOfWork;
private readonly UserManager<ApplicationUser> _userManager;
public Weather Weather { get; set; }
public ForcastController(IWeatherRepository weatherRepository, IUnitOfWork unitOfWork,
UserManager<ApplicationUser> userManager)
{
_weatherRepository = weatherRepository;
_unitOfWork = unitOfWork;
_userManager = userManager;
}
public async Task<IActionResult> Index()
{
// ApplicationUser applicationUser = await _userManager.GetUserAsync(User);
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
var user = await _userManager.FindByIdAsync(userId);