How to differentiate ASP page Refresh versus Requested by other pa

Ask a Question related to ASP Components, Design and Development.

  1. #1

    Default How to differentiate ASP page Refresh versus Requested by other pa

    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 Guest

  2. Similar Questions and Discussions

    1. how can i Refresh my page????
      Please help me I am using mac os x and Dreamweaver MX 2004, But i make some page but I am not abble to see them normal, please help me....I will...
    2. Page Refresh
      OK, I have created a user control that contains a dropdown for office locations. Here is the code.... Private Sub Page_Load(ByVal sender As...
    3. page refresh?
      I have the submit and action page. On the submit form, I have several text boxes for user to enter information. On the action page, I have the...
    4. Two questions: datagrid with string[] and how to differentiate between columns
      This is my first attempt at creating an ASP.Net app and first using the datagrid. Seems pretty nice but there are some peculiarities I can't figure...
    5. refresh a page every so often
      I want to refresh the text of a label box, say, every second. Is there a way to maintain some kind of persistent connection to the server and the...
  3. #2

    Default Re: How to differentiate ASP page Refresh versus Requested by other pa


    "adam" <adam@discussions.microsoft.com> wrote in message
    news:BFA43B05-8897-4931-85F6-F223614DADFD@microsoft.com...
    > 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
    A referesh will use the same method to request the resource. If the page is
    navigated to by means of a POST then the browser will use a POST to refresh
    (it keeps a copy of the original request body in order to do that). So
    REQUEST_METHOD doesn't help. Even the Referrer header remains the same.
    The only difference in the request generated by a refresh is the inclusion
    of a Pragma: nocache header and a Cache-Control: max-age=0 which will force
    any cache/proxy between the browser and the origin server to forward the
    request to the server. Unfortunately these headers are not exposed in the
    ServerVariables property.

    I'm gonna guess you are trying to prevent a Form post duplicating activities
    when the user refreshes the resulting page.
    Add a hidden field to the original form to hold a unique transaction ID ( a
    GUID or sequential number). When you have processed the posted data, mark
    the transaction ID as processed. In your processing page before doing
    anything else check that the transaction ID hasn't already been processed.
    If it has just do the output part of the page.

    Anthony.


    Anthony Jones Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139