Is it possible to obtain ASP.NET membership user name after FormsAuth.SignIn ?
Posted
by Simon_Weaver
on Stack Overflow
See other posts from Stack Overflow
or by Simon_Weaver
Published on 2009-11-15T04:39:11Z
Indexed on
2010/04/26
18:43 UTC
Read the original article
Hit count: 158
asp.net-membership
|formsauth
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).
© Stack Overflow or respective owner