How to manipulate back button in ASP.NET 4?

After searching a lot of references. I have came to a conclusion that you can only prevent user from accessing the previous page is thru javascript window history. You can not manipulate the forward button but only the back button. There are many ways to do it, if you really want to manipulate both button is to clear cache like this,
Response.Buffer = true;
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
Response.Expires = 0;
Response.CacheControl = “no-cache”;

To manipulate the previous page (back button) is thru this way,

<script type=”text/javascript” language=”javascript”>

function DeleteHistory() {
window.history.go(‘Default.aspx’);
}
setTimeout(“DeleteHistory()”, 1000);
window.onunload = function () { DeleteHistory(); };
</script>

Here are references that I have used:
Reference 1
Reference 2
Reference 3
Reference 4
Reference 5
Reference 6
Reference 7
Reference 8
Reference 9
Reference 10
Reference 11

Javascript back button asp.net
Reference 12
Reference 13
Reference 14
Reference 15
Reference 16
Reference 17
Reference 18
Reference 19

Advertisements
This entry was posted in ASP.NET 4, ASP.NET 4 And Javascript, JavaScript. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s