Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 16, 2012 12:04 AM by oned_gk
Dec 15, 2012 05:11 PM|LINK
I'm having trouble with the Membership.GetUser() function. I have created a user and can log in via the login function. Initially, I return the username of the validated user (firstname.lastname@example.org). However, when I do a postback or visit any other section,
the Membership.GetUser() function returns null.
I have verifed that the user and userId exists in aspnet_Membership, aspnet_Roles and aspnet_UsersInRoles in the SQLServer 2008 DB.
Has anyone ran into anything like this before? Thanks for your help.
Dec 15, 2012 06:34 PM|LINK
If all you need is the username, then don't waste a trip to the database -- just call
User.Identity.Name. But this might be empty which would explain why the call to membership returns null. But knowing if User.Identity.Name is empty of not will help diagnose the problem.
Dec 15, 2012 06:47 PM|LINK
Thanks BrockAllen. Upon further investigation, I found that the .ASPXAUTH cookie is not being set for certain users, but is being set for other users. I don't know how the user is being authenticated, but yet not receiving the .aspxauth cookie.
Dec 15, 2012 09:41 PM|LINK
Ah - Another programmer had placed a logout function deep withing a Control. Thanks anyways!
Dec 16, 2012 12:04 AM|LINK
If you get right user in login page then
This will set .ASPXAUTH value and will redirect to target page or default page.