Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > How to differentiate Page requested versus Page refresh

Reply
Thread Tools

How to differentiate Page requested versus Page refresh

 
 
adam
Guest
Posts: n/a
 
      06-21-2006
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
 
Reply With Quote
 
 
 
 
John Beschler
Guest
Posts: n/a
 
      06-21-2006
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

 
Reply With Quote
 
 
 
 
Larry Bud
Guest
Posts: n/a
 
      06-21-2006

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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Re: Mozilla versus IE versus Opera versus Safari Peter Potamus the Purple Hippo Firefox 0 05-08-2008 12:56 PM
equal? versus eql? versus == versus === verus <=> Paul Butcher Ruby 12 11-28-2007 06:06 AM
Char to visually differentiate folders from some live bookmarks/feeds. Splibbilla Firefox 0 04-19-2005 11:25 PM
How to differentiate between <XX></XX> and <XX/> with SAX dpj5754@yahoo.fr XML 13 08-11-2004 12:02 AM



Advertisments