How to differentiate Page requested versus Page refresh

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • adam

    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_Re sult.asp" got reloaded itself when user click on the browser
    Refresh button or is requested by the previous page "Application_Fo rm.asp".

    I tried using
    <%if Request.ServerV ariables("REQUE ST_METHOD") = "POST" then%>
    <!--it is requested from "Application_Fo rm.asp, do something-->
    <%else%>
    <!--Application_Res ult.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

    #2
    RE: How to differentiate Page requested versus Page refresh

    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:
    [color=blue]
    > Hi ASP Expert,
    >
    > I encounter a page reload situation in ASP.
    > It is I need a way to differentiate whether the current page -
    > "Application_Re sult.asp" got reloaded itself when user click on the browser
    > Refresh button or is requested by the previous page "Application_Fo rm.asp".
    >
    > I tried using
    > <%if Request.ServerV ariables("REQUE ST_METHOD") = "POST" then%>
    > <!--it is requested from "Application_Fo rm.asp, do something-->
    > <%else%>
    > <!--Application_Res ult.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[/color]

    Comment

    • Larry Bud

      #3
      Re: How to differentiate Page requested versus Page refresh


      adam wrote:[color=blue]
      > Hi ASP Expert,
      >
      > I encounter a page reload situation in ASP.
      > It is I need a way to differentiate whether the current page -
      > "Application_Re sult.asp" got reloaded itself when user click on the browser
      > Refresh button or is requested by the previous page "Application_Fo rm.asp".[/color]


      I take it your application_res ult.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.redire ct to the SAME PAGE as the
      post after the data. So in application_res ult.asp, do

      response.redire ct("applicaton_ result.asp")

      Since the response.redire ct 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.

      Comment

      Working...