473,387 Members | 1,476 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to differentiate Page requested versus Page refresh

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
2 2622
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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows...
14
by: sinister | last post by:
I have some CGI programs that spit out error pages when the user enters illegal form input. These custom error pages, while informing the user of errors, are otherwise just standard web pages. ...
9
by: PK9 | last post by:
I'm having an issue with the "Refresh" of an asp.net page. The refresh is actually calling my last onClick event. I thought that asp.net was supposed to be stateless in that it shouldn't...
12
by: ACaunter | last post by:
Hi all, I was wondering how i could write some code which would automatically open the Login Page once the session has expired? -- AdamPC@hotmail.com
2
by: sanjeevcis | last post by:
Hi Everybody, Is there any way to differentiate window closing and window refreshing. Actually I need the code regarding this. I want to get the Popup when i...
1
by: killygolaman | last post by:
Hi Guys, Have been looking at this for a while and not sure if there is a solution but hopefully someone can point me in the right direction: The problem is essential I want to undo an update...
11
by: PW | last post by:
One of my ASP's was working fine for a long time. Now it has started constantly refreshing itself. Everytime I run it I just get the first part of the page, then it refreshes itself, the rest of...
3
by: Mike | last post by:
Is there a way to determine if a page was refreshed? I have a function that is called when the page loads, but when the user refreshes the page it calls the function again. Is there a way to call...
7
by: seanmatthewwalsh | last post by:
Hi I have a page (default.aspx) that pulls it's HTML from a database. I then have a "content management" page (editpage.aspx) that allows the user to edit the HTML in the database. When the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.