By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,544 Members | 2,002 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,544 IT Pros & Developers. It's quick & easy.

Page redirection history

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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

"Tim Marsden" <TM@UK.COM> wrote in message
news:#K**************@TK2MSFTNGP11.phx.gbl...
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

Nov 18 '05 #2

P: n/a
Use Server.Transfer to navigate to Page2 and Response.Redirect to navigate to Page3. Server.Transfer will not create an entry in a browser's history.

http://msdn.microsoft.com/library/de...anotherpage.as

Svetlan
Nov 18 '05 #3

P: n/a
"Tim Marsden" <TM@UK.COM> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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.
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #4

P: n/a
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


Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.