MemberShip.GetUser() and login control

F

Florian Paulus

Hello group,

i'm trying to load some additionally stored information to a user at
login time.

That data is self created and stored in an sql database.

I hooked in the login control definiton with : OnLoggedIn="loadMyUserData"

The following code should show what i'm trying to do (i removed the part
of working with this data) :

public void loadMyUserData(object sender, EventArgs e)
{
ContactDetailsService.getInstance().getContactDetailsForUser(Membership.GetUser());
}

I get a null reference exception, so MemberShip.GetUser() does not know
about the currently logged in user at this time.

My question is, where can i hook to access the currently logged in user
during this login process and before the user is automatically
redirected to the specified page? I know that i could read the username
from the login form, get the MemberShipUser for that username and pass
this, but it seems not nice.

Any ideas?

Thanks in advance

Florian
 
E

Eliyahu Goldin

The authentication principal won't get set until the next request to the
server. That's why GetUser returns null. But you can use the "UserName"
property of the Login control. With this name, you can use
Membership.GetUser(userName).


--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
F

Florian Paulus

Eliyahu said:
The authentication principal won't get set until the next request to the
server. That's why GetUser returns null. But you can use the "UserName"
property of the Login control. With this name, you can use
Membership.GetUser(userName).
Thank you for your answer, so seems i'll have to do it that way.

Florian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top