Get custom property of signed in user in .NET Core

asp.net-core-1.0 asp.net-core-mvc c# entity-framework-core

Question

I'm working on a .NET Core project and I have added a custom column to the ASPNetUsers table called DisplayName that users set during the registration. I've successfully migrated the tables with that data and everything works fine.

However in my Login partial, I have to access the user's data through UserManager, and there's no method of getting that DisplayName INSTEAD of the Username.

What do I need to do to extend the function of the "normal" Identity manager to get the custom method to retrieve the text that's stored in DisplayName column?

1
0
6/13/2018 2:55:15 PM

Popular Answer

By getting the current user I can then access the DisplayName property as a normal property of an object.

var currentUser = await _UserManager.GetUserAsync(User);
var displayName = currentUser.DisplayName;
0
6/13/2018 3:14:43 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow