Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have created custom login page..

in which i am validating a user like below :

C#
if (Membership.ValidateUser(txt_email.Text, txt_password.Text))
             {
                 FormsAuthentication.RedirectFromLoginPage(txt_email.Text, cmb_remeber.Checked);

             }


It is working fine. but what i actually want is if user is validated succesfully then user should go in logged in state... And loginStatus control should show Logout. it is being validated successfully but loginstatus is not go in loggedIn state..

what to do to achieve this???
Posted

To check if a user is already logged in using forms authetication, try HttpContext.Current.User.Identity.IsAuthenticated.
C#
if(HttpContext.Current.User.Identity.IsAuthenticated)
{
    //Do stuff
}
 
Share this answer
 
Comments
Harpreet_125 16-Mar-14 3:15am    
Sorry, but you did not understand my question..
Harpreet_125 16-Mar-14 3:17am    
your code will return false in my case... that's the problem..
Abhinav S 16-Mar-14 3:26am    
If you are using forms authentication, you will need to sign in first. Only then, you can check for login state.
vv_shameer 16-Mar-14 7:07am    
Check the LoginText and LogoutText property of LoginStatus control.
Why don't you use LoginStatus[^] !
Quote:
The LoginStatus control displays a login link for users who are not authenticated and a logout link for users who are authenticated. The login link takes the user to a login page. The logout link resets the current user's identity to be an anonymous user.


-KR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900