Page redirection history

T

Tim Marsden

Hi,

If I navigate from Page1 to Page2 then to Page3, using the
response.redirect.

When the user press the Back button, I what then to go to Page 1 and start
again, not Page2. I dont want the to navigate to Page2 using the Back and
Forward buttons.

How do I do this.

Tim
 
M

Martin Marinov

You have to do it manually - save the redirection history in session objects
so when you go to some page check if the last page that is visited is the
page that must be visited before this. if not redirect to the first page

example:

Visit Page1 (add page1 to the session, you can do it with the page name )->
To to Page 2 ( in page load check if previous page is Page 1. if not go to
page1 )
->Go to Page3 ( the same as in page2 checking )

for collecting the pages you can have a hashtable ( the index of visited
pages will the key - 1,2,3 ..., array - the index of visited pages will be
the index )

Hope this helps

Regards
Martin
 
J

John Saunders

Tim Marsden said:
Hi,

If I navigate from Page1 to Page2 then to Page3, using the
response.redirect.

When the user press the Back button, I what then to go to Page 1 and start
again, not Page2. I dont want the to navigate to Page2 using the Back and
Forward buttons.

You would have to tell the user's web browser not to allow the "back"
button. You'd probably also want it not to allow the user to manually enter
the URL for page 2.

Otherwise, the user will be able to do whatever the user wants, which may
very well be what the users expect.
 
S

Steven Cheng[MSFT]

Hi Tim,

As for how to prevent the browser navigate a certain page in the history
list when we hit back button, here are some of my suggestions:

Generally, when we navigate to a page in the browser, the url will be loged
into the Browser's history lists. And when we hit "back" button, the
browser will go back according to the history url array. One way to avoid
the current page's url be added into the history list is using the
"window.location.replace(url)" javascript function, this method will
redirect the browser location to another url and the important thing is
that it won't add a new item in the history list but replace the previous
page's history url item. So as for your situation, you can do the folliwing
steps to implement your task:
1.use any means to redirect from page1.aspx to page2.aspx

2. in page2.aspx , we use clientside script to redirect rather than use
serverside code, for example , use the following function
<script language="javascript" >
function NoHistoryRedirect(url)
{
window.location.replace(url);
}
</script>

in a button's client click event , call "NoHistoryRedirect('page3.aspx');"

this will change the current page's location to the speicified url and
replace the url in the browser's history url list. So that when we hit
"back" button, it won't stop at page2.
Please have a try to see whether it helps. thanks.

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.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top