Reputation: 21275
My users log in using an email address and their password using my custom membership provider. Is there a way to have User.Identity.Name
(or something else within there) return the users real name and not their username (or email address in my case) while keeping the email address so that can still be used? If that isn't a good way to do what I want, what do you recommend to do instead?
I think "Welcome Mike Wills" looks better than "Welcome [email protected]".
Upvotes: 0
Views: 2073
Reputation: 30152
The best way here is to implement a custom principle so the fields are available, don't try to 'misuse' existing fields. Simply cast the IPrinciple usage to your principle class and reference the FullName field (or whatever you call it)
Implementing IPrincipal and IIdentity in MVC with use of custom membership and role provider
Upvotes: 1
Reputation: 6719
You can add the user's profile object (or name) to a Session
variable, so you won't have to query the database for each pageload.
Upvotes: 2
Reputation: 31378
A separate "Users" DB table to store personal info that is related to the Membership table....
That way it keeps your authentication and authorization data separated from (but linked to) your custom user data. Makes it easier to manage IMHO.
Upvotes: 0