Last post May 28, 2012 03:02 AM by Steven Cheng - MSFT
May 25, 2012 07:16 PM|usman_sodon|LINK
I am trying to get the email of registered user by User.Identity.GetProfile().Email; (I got them registered from ASP memebership)
but it always give error or object refereenced to null .
The data of user is present in DB , mne objective is to use these built in classes to get info of users both logged in and all other users .
May 25, 2012 08:34 PM|BrockAllen|LINK
Is GetProfile() an extension method because it's not defined on the IIdentity interface?
Here's how I'd get the email (no error/null checking but you can add that):
var email = Membership.GetUser(User.Identity.Name).Email;
May 28, 2012 03:02 AM|Steven Cheng - MSFT|LINK
As BrockAllen mentioned, the membership provider can let you specify an email address for a given user. Or if this is not the case, you can also use ASP.NET Profile provider to add more custom properties for a given user. And you can use the Profile APIs
to get and update those properties for each user:
#ASP.NET Profile Providers
#Profiles In ASP.NET 2.0