• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 91
  • Last Modified:

Get EMail from AspNetUser

I have a asp.net Web application (web forms), for which I am tryig to retreieve the currently logged in users email address from the database.

I've added the field to my IdentityModel as such:

  public class ApplicationUser : IdentityUser
    {
        public string Email { get; set; }

        public ApplicationUser()
        {
            
        }
    }

Open in new window


But, whenever I try and obtain this informaiton, using the ApplicationUser, I'm not seeing it

User not showing Email field.
What am I missing, in order to see this value?
0
Wayne Atherton
Asked:
Wayne Atherton
1 Solution
 
Lokesh B RDeveloperCommented:
Hi,

try this

if (user != null)
{
    email = user.Email;
}

Open in new window


Or if you are using memberShip

var user = Membership.GetUser(User.Identity.Name);
var email = null;

if (user != null)
{
    email = user.Email;
}

Open in new window


https://msdn.microsoft.com/en-us/library/40w5063z(v=vs.110).aspx
0
 
Wayne AthertonProduct Analyst Financial Messaging LondonAuthor Commented:
now i just feel silly :-) THanks @Lokesh B R
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now