I am writing an ASP.Net Core Web Application, using the template as my starting point. I have added a couple of custom fields to my ApplicationUser which have an impact on what data I return from my controller actions.
At the moment I am doing the following in each controller where I need to look up these fields:
ApplictionUser user = await _userManager.FindByIdAsync(User.FindFirstValue(ClaimTypes.NameIdentifier));
This works fine, but I am wondering if this is the correct way to go about this; making a db lookup in every action for the user details or should I be caching the retrieved user in some way?
If you don't need to update the user info in Db frequently ,you could cache the receviced user following the docuemnt