Clear Browser history,asp.net with C#

Asked By Saurabh ......
06-Sep-08 08:26 AM
Earn up to 0 extra points for answering this tough question.

how to clear the bowser history using c#

i m unable to call javascript function "windows.history.clear"  form serverside.

 

  Use Javascript

Shailendrasinh Parmar replied to Saurabh ......
06-Sep-08 08:43 AM

Try this one ::

Yes, you can clear browser history through javascript....

//clears browser history and redirects url

<SCRIPT LANGUAGE=javascript>
{
  var Backlen=history.length;   history.go(-Backlen);
  window.location.href=page url
 }
</SCRIPT>

Also see this link :: http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_23052591.html

Hope it helps

  try this

ram kumar replied to Saurabh ......
06-Sep-08 12:46 PM

Hi,

 

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>");

   }

  U cannot do that with javascript

Binny ch replied to Saurabh ......
06-Sep-08 01:16 PM
You cannot clear the existing history but you can make sure a newly
selected page replaces the previous one preventing building up a
history. You do so by calling
location.replace('newPage.htm');
instead of assigning
location.href = 'newPage.htm';
The location.replace('url') call will replace the current page in the
history list with the new page thus preventing backing to the current
page.
You might also use that in a link with
<A HREF="newPage.html"
ONCLICK="location.replace(this.href); return false;"
>new page</A>

  call java script function from server side
Sat Sat replied to Saurabh ......
07-Sep-08 03:07 AM
on button click write down

string str = "<script>windows.history.clear() ; </script> "

Page.RegisterClientScriptBlock("xxx",string);

This will register a script while rendering at the end of page .
you can refer
http://www.revenmerchantservices.com/ajax/RegisterClientScriptBlock.aspx

  Deleting history of browser? Please don't do this.
Eriawan Kusumawardhono replied to Saurabh ......
07-Sep-08 11:49 AM
Hi,

Although IE has the ability to delete the browser's history, I advice you not to do this!

Browser history is not just your web page history, it also can contain other web page history, not just yours. If your web page is opened side by side with other web pages from other sites especially ecommerce or portal sites, you'll upset your user if you clear the browser history! After history cleared, the browser has no ability to do its client page state management that goes with the history.

If you don't want to deal with browser history, you can simply make the web page's of your web application session to be expired for a very short time.

Eriawan
  try this.
Vasanthakumar D replied to Saurabh ......
08-Sep-08 12:33 AM

Hi,

try the belwo one..

Page.ClientScript.RegisterStartupScript(this.GetType(),"cle","windows.history.clear",true);

Create New Account