Last post May 27, 2012 10:02 PM by Steven Cheng - MSFT
May 25, 2012 02: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 03: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 27, 2012 10:02 PM|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