473,395 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to prevent Postback URL's from being added to browser history

Rob
Each time a webform is posted back (submitted), another URL is added to the browser's history list. My web application allows a back button to return to previously visited pages, but I do not wish to return to each Postback URL, but rather only the initial page URL. Is there a way to prevent Postback URL's from being added to the browser's history list

Thanks in advance for any help.
Nov 18 '05 #1
3 9948
If you turn on smart navigation (Page.SmartNavigation property) on the page it will prevent postbacks from being added to the history (as well as other nice features). CHeck out browser compatibility issues though to make sure it works in non-IE browsers - or at least see if it fails gracefull

hope this help
Michael
Nov 18 '05 #2
Hi,
Thank you for using MSDN Newsgroup! My name is Steven, and I'll be
assisting you on this issue.
From your description, you are looking for some approachs on how to prevent
Postback URL's from being added to the browser's history list so that
customer can only navigator to the initial view of a page or refresh again
to get a new version of the certain page.
If there is anything I misunderstood, please feel free to let me know.

First of all, I should confirm msdnalias's suggestion that use the
"SmartNavigation" property of the ASP.NET web page. This is a very good
solution. In fact, one of the functionality fo "SmartNavigation" property
is:
retaining only the last page state in the browser's history.
Thus, only the different navigatored page will be added to the history
list. The post back page with same url won't be added into. To enable the
"SmartNavigation" property, just change the certain page's
"smartNavigation" property to "true" in the property window of VS.NET, also
you can programmatically set it as below:
Page.SmartNavigation = true;

Also, there're many other wonderful features of the "smartNavigation"
property, for detailed info, you can view the following link in MSDN:
http://msdn.microsoft.com/library/en...webuipageclass
smartnavigationtopic.asp?frame=true
In addition, as for the history page which we can visit use the "back" or
"forward" button of IE, they're all the page cache on the client machine.
If you don't want the client cache for a certain, you may also manually
disable them on the serverside code, such as:

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here

Response.CacheControl = "no-cache";
Response.AddHeader("Pragma", "no-cache");
Response.Expires = -1;

}

Thus, if you request this page and then navigator to other pages or event
fire some post back events of the page and then use "back" button to go
back. The Browser will display the following information:
----------------------------------------------
Warning: Page has Expired The page you requested was created using
information you submitted in a form. This page is no longer available. As a
security precaution, Internet Explorer does not automatically resubmit your
information for you.

To resubmit your information and view this Web page, click the Refresh
button.
----------------------------------------------

Thus, will also force you to refresh the page and request a new version of
it. And here is a KB article which particularly discus on this tech topics,
you may have a look if you have interests:

#HOWTO: Prevent Caching in Internet Explorer
http://support.microsoft.com/?id=234067

Any way, please check out the preceding suggestions and choose the proper
one as you like. Also, if you feel them still not quite suitable for your
situation, please feel free to let me know. I'll be willing to help you
search for some other approachs.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #3
Hi,
I've reviewed the issue and found that one suggestion I provided in the
last reply need a bit modification. When only using the below code:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here

Response.CacheControl = "no-cache";
Response.AddHeader("Pragma", "no-cache");
Response.Expires = -1;

}

the end user will see an error "Warning: Page has Expired ...." if the page
is expired and the end user tries to use the "back" button. Actually, it's
a little more complex. You only get the page expired warning if you
previously submitted the page prior to clicking the back button.

To avoid this, we can use the new code as below:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here

Response.CacheControl = "no-cache";
Response.AddHeader("Pragma", "no-cache");
Response.Expires = -1;

if(IsPostBack)
{
Response.Write("post back");
}

}
Then we browsed the page followed by browsing some other page. Then we
clicked the back button and we can see this page with the button on it.
There was no "page has expired" warning message.
---
Also, there is another way to keep a page from being in the history list is
to use window.open("NewPage.aspx",,,false). This must be done when LEAVING
the page that you don't want in the history. The new page replaces the
previous page in the history list. See
http://msdn.microsoft.com/workshop/a...ods/open_0.asp
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ross Pellegrino | last post by:
Hi I know about Component Licensing. However, that Component Licensing is not well suited for my particular need. I understand about runtime and design time components but I want my components...
0
by: Mark Petersen | last post by:
Is there a way to prevent a page postback from being added to the browser history without using SmartNavigation? I'd like to be able to do this in a cross-browser compatible way (modern...
7
by: George | last post by:
I am trying to set up a login-logout website. I have a cookie about the login status. I put it as logout once the logout link is clicked. And I put a little security check about the status of...
4
by: Dave Carroll | last post by:
We are developing a secure site. One a user logs off of the site we do not want them to have the ability to hit the back button and display the secure pages on the site. We started to look at...
0
by: Itai | last post by:
How does smartNavigation prevent Postback URL's from being added to the browser History?
2
by: | last post by:
I am working on an ASP.NET application that seems to be limiting browser histories to only one entry. I am not using SmartNavigation on any of the pages, and that is the only thing that I have...
3
by: Shimon Sim | last post by:
Hi Is it possible to make sure that the page doesn't show in browser history and won't effect Back button. The problem is that every postback shows as another entry for "Back" button and user...
6
by: Trastabuga | last post by:
On the current page the user is at I need to write something like "Please, wait" (I am using document.write for this) and then open a new url with some lengthy calculation process so the page will...
2
by: =?ISO-8859-1?B?UOVsIEEu?= | last post by:
Have a "standard" asp.net web solution which uses the standard asp.net authentication and authorization methods (forms authentication). Some users have raised concern that even if you logout...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.