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

"Previous page" ?

P: n/a
TR
In an "Abandon Changes" button on my UserPreferences.aspx form, I'd like to
redirect back to the page the user was on before coming to the
UserPreferences form. It could be any one of my web app's pages with a link
to the UserPreferences page in its topmenu. (I'm testing for stale session
tokens and can prevent users from bookmarking the page.) However, in
codebehind for the AbandonChanges click event, the REFERRER is the
UserPreferences page itself, having posted to itself. Does asp.net keep
track of the "actual previous page" so to speak, when the previous page is
from the same web application? Or is that sort of state tracking up to the
developer?
Thanks
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi TR,

The problem you're dealing with is a facet of the WebForm object model. As a
WebForm posts back to itself, and the Referer is the last page visited, the
Referer is as likely to be the same page as it is to be another.

The solution is to keep track of the Referer (persist it in ViewState, most
likely) after the first time the page is visited. This can be done using a
conditional statement to check if the Referer's URL is the same as the
current page, and only saving it if it is not.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"TR" <TR@nowhere.biz> wrote in message
news:OF**************@TK2MSFTNGP09.phx.gbl...
In an "Abandon Changes" button on my UserPreferences.aspx form, I'd like
to
redirect back to the page the user was on before coming to the
UserPreferences form. It could be any one of my web app's pages with a
link
to the UserPreferences page in its topmenu. (I'm testing for stale session
tokens and can prevent users from bookmarking the page.) However, in
codebehind for the AbandonChanges click event, the REFERRER is the
UserPreferences page itself, having posted to itself. Does asp.net keep
track of the "actual previous page" so to speak, when the previous page is
from the same web application? Or is that sort of state tracking up to the
developer?
Thanks

Nov 19 '05 #2

P: n/a
TR
Thanks for the helpful suggestion, Kevin.
TR

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:#m**************@TK2MSFTNGP14.phx.gbl...
Hi TR,

The problem you're dealing with is a facet of the WebForm object model. As a WebForm posts back to itself, and the Referer is the last page visited, the Referer is as likely to be the same page as it is to be another.

The solution is to keep track of the Referer (persist it in ViewState, most likely) after the first time the page is visited. This can be done using a
conditional statement to check if the Referer's URL is the same as the
current page, and only saving it if it is not.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"TR" <TR@nowhere.biz> wrote in message
news:OF**************@TK2MSFTNGP09.phx.gbl...
In an "Abandon Changes" button on my UserPreferences.aspx form, I'd like
to
redirect back to the page the user was on before coming to the
UserPreferences form. It could be any one of my web app's pages with a
link
to the UserPreferences page in its topmenu. (I'm testing for stale session tokens and can prevent users from bookmarking the page.) However, in
codebehind for the AbandonChanges click event, the REFERRER is the
UserPreferences page itself, having posted to itself. Does asp.net keep
track of the "actual previous page" so to speak, when the previous page is from the same web application? Or is that sort of state tracking up to the developer?
Thanks


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.