Monday, July 28, 2008

How To Clear Browser Session In Asp.net




In this post i will show how to clear Browser history in asp.net.just write down following code in Logout button.

protected void LogOut()
   {
       Session.Abandon();
       string nextpage = "Logoutt.aspx";
       Response.Write("<script language=javascript>");

       Response.Write("{");
       Response.Write(" var Backlen=history.length;");

       Response.Write(" history.go(-Backlen);");
       Response.Write(" window.location.href='" + nextpage + "'; ");

       Response.Write("}");
       Response.Write("</script>");

   }

6 comments:

pankaj sharma said...

this code not working

send other code in my mail id

santosh said...

@Pankaj : can i have your email address?

kumarvinit86 said...

this is not working properly...can u send it to my mail my mail id is, kumarvinit86@gmail.com

Sowdamini said...

Hi,
This code is working but when we click on the forward button it is moving to the previous page

Anonymous said...

This code is not working.

Naveen said...

Not working...my requirement is i hav one form with 2 textboxes...afetr submitting the values..the browser needs to be get cleared.. means the values i enetred already should not appear when i click the control to enter 2nd record..

Post a Comment