How to differentiate Page requested versus Page refresh

A

adam

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
 
J

John Beschler

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
 
L

Larry Bud

adam said:
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.
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top