ASP.NET Postback Refresh Problem

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Re: ASP.NET Postback Refresh Problem

    If you want to stop this happening, what you could do is a response.redirect
    back to the same page, after your server side event has finished running.
    This would reload the page afresh, and when the user hits refresh, it
    wouldn't prompt them to re-post the form data.

    E.g.

    Protected Sub Button1_Click Handles Button1.Click

    'Your custom code here
    Dim foo As String = "foo"

    'Redirect back to this page when done
    Response.Redirect(Request.Path)

    End Sub

    Although it would solve the problem, it would be an additional server round
    trip, though I'm not sure it can be avoided...

    You could try using Server.Transfer(Request.Path, False), but I don't think
    this would work as the page redirect would happen in the background, and
    when the user refreshes, it would still prompt them to re-post the form
    data.

    Hope this helps,

    Mun




    "ChiCKeN DaViS" <ChickenD@nbnet.nb.ca> wrote in message
    news:0b7201c352aa$2c300b90$a101280a@phx.gbl...
    > Hello there,
    >
    > I have a rather tough question to answer related to page
    > refresh. When visiting a webform for the first time a
    > given user can refresh the page as much as he/she likes
    > and all is well. When a postback occurs (ie. button
    > click, select in datagrid, etc...), the browser will post
    > back to the server and the associated server-side event
    > for that webcontrol will run. Now the postback has
    > happened and whatever server side processing has been
    > done... at this point ...if the user trys to refresh
    > they will see the dialog that says ...
    >
    > "The page cannot refresh without resending the
    > information. Click retry to send the information again,
    > or click cancel to return to the page that you were
    > trying to view"
    >
    > If they click retry ...then the server will re-post the
    > webform back to the server and cause that previous server-
    > side processing to happen again (ie. run page_load again
    > and run a button_onClick again, etc..). I have seen very
    > few people mention this problem... This surprises me
    > because it is a really big problem. There has to be some
    > way around it, otherwise.. what good is ASP.NET? :( Of
    > the solutions I have seen ...none of them make any
    > sense. Seems only people who dont know what they're
    > talking about try to provide a solution to this problem.
    >
    > It doesn't matter if you provide a server side solution
    > or client side. I just need some sort of solution to
    > prevent the same events running multiple times as a
    > result of refresh. If there is a way of detecting a
    > refresh, thats fine too cuz i can suppress the server-
    > side processing from happening again if i know its a
    > refresh.
    > I just can't think of or find any way to detect this.
    >
    > If there is no way to prevent this .. then every other
    > asp.net web application ever built will have this problem
    > too.. which is just ridiculous!
    >
    > Any help is greatly appreciated. :)
    > but im not confident that i will get a solution...
    > considering no one else has...
    >
    > -ChiCKeN DaViS
    >

    Munsifali Rashid Guest

  2. Similar Questions and Discussions

    1. Postback data problem
      I am trying to constuct a custom control in ASP.NET 2.0. I want it to collect the information in the control through postbacks, but I can't seem to...
    2. Datagrid postback problem?!?
      I have a datagrid that works perfectly well. I have default paging turned on and this is where I have a small problem. My datagrid is created via...
    3. Problem with refresh button breaking automatic refresh
      As a public service, I'm posting the solution to a problem I had. The bizarre thing is that I think this should have created an error. Instead, it...
    4. HELP - Problem with DG Postback when not using AutoFillColumns
      I have the following code for the Datagrid. If I set AUTOGENERATECOLUMNS=FALSE. The PageIndexChanged routine does not fire and the Datagrid...
    5. Dialog postback problem
      Hi I have a webform that can show a dialog using javascript . Content of this dialog is an aspx page with a submit button .My problem is when i...
  3. #2

    Default Re: ASP.NET Postback Refresh Problem

    Hi,

    You can keep a session variable and set the value to true at page load event for the first time ie inside "!IsPostBack" condition. then next time onwards you can prevent the execution of set of events first by checking the value of variable stored in the session.
    Unregistered 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