logo

Clear Browser history,asp.net with C# (Visual Studio .NET)
Saurabh ...... posted at Saturday, September 06, 2008 8:26 AM

how to clear the bowser history using c#

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

 

Reply    Reply Using Power Editor
  Rank Winnings Points
February 0 $0.00 0
January 0 $0.00 0
Use Javascript
Sanjay Verma provided a rated reply to Saurabh ...... on Saturday, September 06, 2008 8: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

Reply    Reply Using Power Editor
Asp.Net Developer
  Rank Winnings Points
February 0 $0.00 0
January 19 $0.00 22

try this
ram kumar provided a rated reply to Saurabh ...... on Saturday, September 06, 2008 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>");

   }

Reply    Reply Using Power Editor
  Rank Winnings Points
February 0 $0.00 0
January 0 $0.00 0

U cannot do that with javascript
Binny ch provided a rated reply to Saurabh ...... on Saturday, September 06, 2008 1: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>

Reply    Reply Using Power Editor
  Rank Winnings Points
February 0 $0.00 0
January 0 $0.00 0

call java script function from server side
Sat Sat replied to Saurabh ...... on Sunday, September 07, 2008 3: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

Reply    Reply Using Power Editor
  Rank Winnings Points
February 0 $0.00 0
January 0 $0.00 0

Deleting history of browser? Please don't do this.
Eriawan Kusumawardhono provided a rated reply to Saurabh ...... on Sunday, September 07, 2008 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
Reply    Reply Using Power Editor
An ordinary software developer that mingles with .NET 2.0, WPF, WCF, WF and currently making his way thru .NET 3.5. Very addicted to the latest happening on Microsoft software development tool such as Visual Studio.
  Rank Winnings Points
February 0 $0.00 0
January 0 $0.00 0

try this.
Vasanthakumar D provided a rated reply to Saurabh ...... on Monday, September 08, 2008 12:33 AM

Hi,

try the belwo one..

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

Reply    Reply Using Power Editor
  Rank Winnings Points
February 0 $0.00 0
January 0 $0.00 0


Didn't Find The Answer You Were Looking For?

EggHeadCafe has experts online right now that may know the answer to your question.  We pay them a bonus for answering as many questions as they can.  So, why not help them and yourself by becoming a member (free) and ask them your question right now?
Ask Question In Live Forum

If you have an OpenID and do not want to become a member of the EggHeadCafe forum, you can also sign on to Chat Chaos and post your question to our real time Silverlight chat application.
Ask Question In Chat Chaos










  $1000 Contest    [)ia6l0 iii - $228  |  Jonathan VH - $161  |  Huggy Bear - $135  |  F Cali - $95  |  egg egg - $94  |  more Advertise  |  Privacy  |   (c) 2010