I have a login page that uses ASP.NET membership. Once I’ve validated the user I need to store some details about them in Session variables. The problem is that
Membership.GetUser() == null and
User.Identity.IsAuthenticated == false
until I have navigated away from the page.
I have tried using
FormsAuthentication.Authenticate(tbUsername.Text, tbPassword.Text);
And checking User.Identity.IsAuthenticated but it’s returning false until I reach another page. Any suggestions?
Well,
FormsAuthentication.Authenticate()returns aboolean, so you will know whether or not authentication was successful. If it was, you can pass the user’s username toMembership.GetUser()and access the returnedMembershipUserobject to grab whatever data you need and store it in the session.