Thread: ASP.NET/ASP Net - ASP.NET - Logout from code

ASP Net - ASP.NET - Logout from code

Page_Load

Response.Expires = 60

Response.Expiresabsolute = Now() - 1

Response.AddHeader("pragma","no-cache")

Response.AddHeader("cache-control","private")

Response.CacheControl = "no-cache"


 


or:


 


FormsAuthentication.SignOut



http://msdn2.microsoft.com/en-us/lib...signout.as px


 


 


 





Re: ASP Net - ASP.NET - Logout from code

 


    protected void LoginStatus1_LoggedOut(object sender, EventArgs e)

    {

        FormsAuthentication.SignOut();

        Roles.DeleteCookie();

        Session.Clear();


FormsAuthentication.RedirectToLoginPage();



 





    }





Re: ASP Net - ASP.NET - Logout from code

protected void lnkbtnLogout_Click(object sender, EventArgs e)



{



try



{



FormsAuthentication.SignOut();



Session.Abandon();



Response.Cache.SetCacheability(HttpCacheability.Private);



Response.Cache.SetCacheability(HttpCacheability.NoCache);



Response.Redirect("~/Login.aspx");



}



catch (Exception ex)



{







throw ex;



}



}





Re: ASP Net - ASP.NET - Logout from code

protected void logout()

{

Response.Cache.SetCacheability(HttpCacheability.NoCache);

Session.Clear();

FormsAuthentication.SignOut();

DisableBufferingOnPage()

}



protected void DisableBufferingOnPage()

{

Response.Buffer = true;

Response.ExpiresAbsolute = DateTime.Now.AddDays(-1); // set expiry date in the

past

Response.Expires = 0;

Response.CacheControl = "no-cache";

Response.Cache.SetNoStore();

Response.AppendHeader("Pragma", "no-cache");

}