How to get user profile values ​​in ASP.NET Identity 2 of the current user?

In an MVC5 application, how do you get the values ​​from the AspNetUsers table for the current user?

For example: one of the default files is PhoneNumber. How do you get the phone number of the current registered user?

I am using Identity 2 ...

+4
source share
1 answer

IdentityUser (, , ApplicationUser ) Entity Framework. , , . , , , User, UserManager<TUser>.FindById() :

// UserManager here is an instance of UserManager<ApplicationUser>
var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
var number = user.PhoneNumber;
+3

Source: https://habr.com/ru/post/1537662/


All Articles