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:
usman_sodon
Member
234 Points
154 Posts
Get Email from User.Identity.Profile().Email()
May 25, 2012 06:16 PM|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 .
BrockAllen
All-Star
27516 Points
4898 Posts
MVP
Re: Get Email from User.Identity.Profile().Email()
May 25, 2012 07:34 PM|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;
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
Steven Cheng...
Contributor
4199 Points
548 Posts
Microsoft
Moderator
Re: Get Email from User.Identity.Profile().Email()
May 28, 2012 02:02 AM|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
http://msdn.microsoft.com/en-us/library/014bec1k.aspx
#Profiles In ASP.NET 2.0
http://odetocode.com/Articles/440.aspx
Feedback to us
Microsoft One Code Framework