I am trying to check when a user is authenticated and I am always getting that the user is authenticated. Here is my code:
if( User.Identity.IsAuthenticated )
{
addProfiledata();
}
This condition always is true even if I log in and log out.
How can I correct this?
if you have defined users role then it should be handled, you are using LoginControl and i guess you are handling sing out sing in with other login controls like loginview and hope you are assigning the user roles to it. if this is a case you can use LoginUser_LoggedIn event
// suppose if you are willing to redirect a user according to his/her role protected void LoginUser_LoggedIn(object sender, EventArgs e) { if (string.IsNullOrEmpty(Request.QueryString["ReturnUrl"])) { // if user in role and authenticated if (Roles.IsUserInRole(LoginUser.UserName, "Developers")) { // add session and redirect to particular page Session.Add("developer", "Developers"); Response.Redirect("../Developers/devAccess.aspx");