Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 03, 2011 12:13 AM by dlmmartin
Jan 18, 2006 07:36 PM|LINK
I tried to use profiles, and save some profile manually (myProfile.save())..etc
I couldn't find a solution. Membership.GetUser() returns null all the time. No matter what!
Also, User.Identity.Name; is empty as well (
I mean even after successful authentication).
As mentioned earlier, on my very system I downloaded another app (mentioned above) and on this one app
User.Identity.Name; returns the right user name and
Membership.GetUser() doesn't return null but the expected User object ...
Please someone help I'm getting desesperate!!!
Jan 18, 2006 07:52 PM|LINK
It's working for me now! Here what I did. I added :
I'm not sure that was solved my problem, I hope it helped someone.
PS: I added the above to the
control. (source view).
Jan 18, 2006 08:16 PM|LINK
Hello people :(
Well, I'm no longer sure it works... actually it does take some time for Membership.GetUser() to work correctly. I have to click here and there than comeback to the page where I check whether the successfuly logged-in User is "recognized" as such. So it
is only after few clicks that Membership.GetUser() returns the right value (and no longer this bloody null value).
Hope someone can figure it out.
Jan 19, 2006 02:11 PM|LINK
Feb 09, 2006 11:39 AM|LINK
I have issued the same problem,
I think in LoggedIn event the httpcontext doesn't refresh itself because you cannot get the user identity calling by membership.getuser() or httpcontext.current.user.identity.name or system.security.threading.thread.currentprincipal.identity.name all these
return null however when you are passed into destination page you can get the user information.
there is a problem with the logged in event while refreshing user httpcontext...
Feb 14, 2006 03:12 PM|LINK
This is "by design". The initial request to the page is anonymous and an auth cookie is already set for this before the event is triggered. In the page response, an authenticated ticket cookie will be sent to the browser and subsequest page requests will
include this cookie so that you'll have an authenticated user.
A workaround is to use the Login control to get the username. For example, "Login1.UserName".
Jun 14, 2006 10:43 PM|LINK
I have a similar problem. The resolutions here did not seem to work.
returns a Data is Null. This method or property cannot be called on Null values. error
The user has logged on successfully and makes it to the correct login view. Why does getuser return a null value?
Thanks in Advance
Jun 15, 2006 08:09 PM|LINK
Feb 20, 2009 09:05 PM|LINK
I know it's been a long time since this thread was posted but I also had the sam problem for a very long time. Then I got my answer from:
http://forums.asp.net/t/1237126.aspx which referred to the simple solution at ScottGu's Blog:
I hope this will help others who would see this post just like me before spending much time.
Membership.GetUser Membership.GetAllUsers() returns null and 0
Jun 08, 2010 06:09 PM|LINK
Also a long time since this thread was refreshed, but I wanted to add what I think is a good answer so the next person that searches this will have something to go on:
Adding this code immediately helped me out - Suddenly Membership.GetUser() works!!! (I'm not sure if you need the Threading principal set, but I thought I'd leave that code for someone to determine their own needs or if using a Winforms or console app)
MembershipUser user = Membership.GetUser(username);
GenericIdentity identity = new GenericIdentity(user.UserName);
RolePrincipal principal = new RolePrincipal(identity);
System.Threading.Thread.CurrentPrincipal = principal;
HttpContext.Current.User = principal;