neonlights
asked on
FormsAuthentication.SignOut is NOT working
Hi..
I am trying to create logout link. When I click on the logout, it is taking me to the logon.aspx page. that is good. But, when i press the back button, it is taking me back to the default.aspx page - it should not.
This is what I have for logout:
public void LoginLink_OnClick(object sender, EventArgs args)
{
Session.Abandon();
Session.Contents.RemoveAll ();
FormsAuthentication.SignOu t();
FormsAuthentication.Redire ctToLoginP age();
}
and in the default.aspx page - form_load:
if (HttpContext.Current.User. Identity.I sAuthentic ated == false)
{
FormsAuthentication.Redire ctToLoginP age();
}
I also have some code in the void Application_AuthenticateRe quest(Obje ct sender, EventArgs e)
String cookieName = FormsAuthentication.FormsC ookieName;
HttpCookie authCookie = Context.Request.Cookies[co okieName];
if (null == authCookie)
{//There is no authentication cookie.
return;
}
I am trying to create logout link. When I click on the logout, it is taking me to the logon.aspx page. that is good. But, when i press the back button, it is taking me back to the default.aspx page - it should not.
This is what I have for logout:
public void LoginLink_OnClick(object sender, EventArgs args)
{
Session.Abandon();
Session.Contents.RemoveAll
FormsAuthentication.SignOu
FormsAuthentication.Redire
}
and in the default.aspx page - form_load:
if (HttpContext.Current.User.
{
FormsAuthentication.Redire
}
I also have some code in the void Application_AuthenticateRe
String cookieName = FormsAuthentication.FormsC
HttpCookie authCookie = Context.Request.Cookies[co
if (null == authCookie)
{//There is no authentication cookie.
return;
}
Looks like the cookie still contains login information, hence erase it as part session out.
ASKER
how do I do that?
Try this:
Response.Cookies.Remove(Fo rmsAuthent ication.Fo rmsCookieN ame);
Response.Cookies.Remove(Fo
ASKER
Thanks Maverick... but, I can still do the back button.. I put remove code in:
Session.Abandon();
Session.Contents.RemoveAll ();
FormsAuthentication.SignOu t();
Response.Cookies.Remove(Fo rmsAuthent ication.Fo rmsCookieN ame);
FormsAuthentication.Redire ctToLoginP age();
Session.Abandon();
Session.Contents.RemoveAll
FormsAuthentication.SignOu
Response.Cookies.Remove(Fo
FormsAuthentication.Redire
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do you have Aynonmous authentication on WebPAges check inetmgr
ASKER
Hi Joex911 - THANK YOU!....
Worked perfectly..
Thanks again.
Worked perfectly..
Thanks again.
ASKER
Right on the target!