Aaron Powell
Aaron Powell

Reputation: 25107

ASP.NET Forms auth - gettings user data

I'm using forms authentication on a very small ASP.NET web app (Web Forms) in which I want to store additional info about the user in a separate database table.

This is then linked back to the aspnet_User table and I was figuring the best column to link to is the UserId column. Problem is I can't work out how to get this piece of data when the user is logged in. Is it even possible?

Also, how do I get the email address?


Before someone points it out, I am aware of the ProfileProvider but the details stored need to be re-submitted each year (it's a registration application for a sporting club) and all previous data stored. So the ProfileProvider isn't really applicable (unless I'm wrong and it can be used to have it stored historically?).

Upvotes: 2

Views: 305

Answers (1)

John Boker
John Boker

Reputation: 83709

here's how you can get the userid

MembershipUser myObject = Membership.GetUser();
string UserID = myObject.ProviderUserKey.ToString();
string Email = myObject.Email;

Upvotes: 2

Related Questions