How do I get a custom field in the aspnetusers table?
2 answers
In any action method, you can get the current user ID by calling the extension method User.Identity.GetUserId()
. And you can get more information using ApplicationUserManager
this:
public ActionResult MyAction()
{
string surname = HttpContext.GetOwinContext()
.GetUserManager<ApplicationUserManager>()
.FindById(User.Identity.GetUserId()).Surname;
}
Make sure you add a namespace Microsoft.AspNet.Identity.Owin
to use the extension method.
+5
source to share
Do you have a custom custom class? If yes ... so "Lastname" will only be one of the properties of the user class (be sure to set PUBLIC)
if you just change TABLE IN DATABASE you can get this property because id doesn't know what this column is because you don't have any class with this structure
0
source to share