I have some code that is accessing Membership.GetUser()
to get the current logged in user.
This works fine until I try to access it immediately after logging in with FormsAuth.SignIn(userName, false);
However I noticed that neither Membership.GetUser()
nor User.Identity.Name
is updated with the newly logged in user until a new request (I assume its reading directly from the Request cookies).
This however kind of screws up my logic that accesses Membership.GetUser()
becasue it introduces a special case.
Question: is there a way to read the current logged in user with ASP.NET membership immediately after logging in. Or will I have to introduce my own abstraction layer to allow me to 'set' a user as being logged in ? (This is in an AJAX request - so i'd rather not do a redirect).