I try to add the username to the cookie and clear it when I log out, but it Request.IsAuthenticatedalways returns true, so I can’t find out if it is a member or not on the next page.
Here is what I am trying:
public void Logout()
{
FormsAuthentication.SignOut();
Session.Abandon();
}
protected void signin_submit_Click(object sender, EventArgs e)
{
HttpCookie authCookie = FormsAuthentication.GetAuthCookie(username_top.Text, true);
}
I click the "Exit javascript function" button and it gets into the debugger, so I'm sure that it was called.
I check the value for Page_Load:
protected void Page_Load(object sender, EventArgs e)
{
bool isAuth = Request.IsAuthenticated;
if (isAuth)
{
registeredDiv.Visible = true;
guestDiv.Visible = false;
}
}
What am I missing? How do I know if a user is logged in or not?
Edit: I found out what is authenticationModeinstalled on Windows in web.config.
Edited as follows:
<authentication mode="Forms">
But now it always returns false. I tried redirecting after entering the same page, but still did not work. Any ideas?