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

How to differentiate Page requested versus Page refresh

P: n/a
Hi ASP Expert,

I encounter a page reload situation in ASP.
It is I need a way to differentiate whether the current page -
"Application_Result.asp" got reloaded itself when user click on the browser
Refresh button or is requested by the previous page "Application_Form.asp".

I tried using
<%if Request.ServerVariables("REQUEST_METHOD") = "POST" then%>
<!--it is requested from "Application_Form.asp, do something-->
<%else%>
<!--Application_Result.asp refreshed itself(such as user clicks on the
browser Refresh button, do something else-->
<%end if%>

However, in both cases, the IF statement above all evaluated as true.
Any idea about how to differentiate this two different behavior (Page
Refresh versus Page requested by another Page) ?

Thanks for your help!

-adam
Jun 21 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Store a value in some session variable.
I.E. Session("MyVAR") = "MyPage")
In the second page test for that value
IF Session("MyVar") = "MyPage" Then
'This page weas called from the previous page
End If
Make sure you clear the session variable so that refreshes do not simply
refresh the var
Session("MyVar") = ""

HTH


"adam" wrote:
Hi ASP Expert,

I encounter a page reload situation in ASP.
It is I need a way to differentiate whether the current page -
"Application_Result.asp" got reloaded itself when user click on the browser
Refresh button or is requested by the previous page "Application_Form.asp".

I tried using
<%if Request.ServerVariables("REQUEST_METHOD") = "POST" then%>
<!--it is requested from "Application_Form.asp, do something-->
<%else%>
<!--Application_Result.asp refreshed itself(such as user clicks on the
browser Refresh button, do something else-->
<%end if%>

However, in both cases, the IF statement above all evaluated as true.
Any idea about how to differentiate this two different behavior (Page
Refresh versus Page requested by another Page) ?

Thanks for your help!

-adam

Jun 21 '06 #2

P: n/a

adam wrote:
Hi ASP Expert,

I encounter a page reload situation in ASP.
It is I need a way to differentiate whether the current page -
"Application_Result.asp" got reloaded itself when user click on the browser
Refresh button or is requested by the previous page "Application_Form.asp".

I take it your application_result.asp page is retriving the form data
and entering it into a database? If so, and your goal is to prevent
someone from reposting data so that it doesn't get entered twice into a
table, what I like to do is a response.redirect to the SAME PAGE as the
post after the data. So in application_result.asp, do

response.redirect("applicaton_result.asp")

Since the response.redirect is NOT a post, if the user refreshes, it's
just reloading the result page. It also doesn't screw up your history
and the user doesn't even know it's happening because it's all done
serverside.

Jun 21 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.