How to differentiate Page requested versus Page refresh

Discussion in 'ASP General' started by adam, Jun 21, 2006.

  1. adam

    adam Guest

    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
    adam, Jun 21, 2006
    #1
    1. Advertising

  2. 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
    John Beschler, Jun 21, 2006
    #2
    1. Advertising

  3. adam

    Larry Bud Guest

    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.
    Larry Bud, Jun 21, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    13
    Views:
    767
    Richard Tobin
    Aug 11, 2004
  2. Replies:
    5
    Views:
    484
  3. Jo
    Replies:
    7
    Views:
    483
  4. Hans-Joerg Unger
    Replies:
    2
    Views:
    1,752
    Martin Honnen
    Apr 10, 2007
  5. Paul Butcher
    Replies:
    12
    Views:
    690
    Gary Wright
    Nov 28, 2007
Loading...

Share This Page