Prevent ASP.NET page to resend data on refresh?

Discussion in 'ASP .Net' started by Asaf, Dec 12, 2007.

  1. Asaf

    Asaf Guest

    Hi,

    How can I prevent from an ASP.NET page to resend all the data again when the
    user press the Refresh button or F5 on the browser?

    Thanks in advanced,
    Asaf
    Asaf, Dec 12, 2007
    #1
    1. Advertising

  2. One easy way to handle this is to set a Session variable the first time the
    page is posted. You can check for the presence of this on any refresh and
    abort resending.
    -- Peter
    Site: http://www.eggheadcafe.com
    UnBlog: http://petesbloggerama.blogspot.com
    MetaFinder: http://www.blogmetafinder.com


    "Asaf" wrote:

    > Hi,
    >
    > How can I prevent from an ASP.NET page to resend all the data again when the
    > user press the Refresh button or F5 on the browser?
    >
    > Thanks in advanced,
    > Asaf
    >
    Peter Bromberg [C# MVP], Dec 12, 2007
    #2
    1. Advertising

  3. Asaf

    Larry Bud Guest

    On Dec 12, 7:44 am, Asaf <> wrote:
    > Hi,
    >
    > How can I prevent from an ASP.NET page to resend all the data again when the
    > user press the Refresh button or F5 on the browser?


    Do a response.redirect after your data is handled to the same page.

    For example, if you're letting the databind do all the work, do a
    response.direct on a datasource inserted (or updated) event.

    If you're handling the data manipulation in code, do it after you do
    all your work.
    Larry Bud, Dec 12, 2007
    #3
  4. Asaf

    Asaf Guest

    Hi Peter,

    I misunderstood your solution, will be much appreciated if you can post an
    example.

    Asaf

    "Peter Bromberg [C# MVP]" wrote:

    > One easy way to handle this is to set a Session variable the first time the
    > page is posted. You can check for the presence of this on any refresh and
    > abort resending.
    > -- Peter
    > Site: http://www.eggheadcafe.com
    > UnBlog: http://petesbloggerama.blogspot.com
    > MetaFinder: http://www.blogmetafinder.com
    >
    >
    > "Asaf" wrote:
    >
    > > Hi,
    > >
    > > How can I prevent from an ASP.NET page to resend all the data again when the
    > > user press the Refresh button or F5 on the browser?
    > >
    > > Thanks in advanced,
    > > Asaf
    > >
    Asaf, Dec 12, 2007
    #4
  5. Hi Asaf,

    For prevent duplicate form submitting, there does exists some session flag
    based approach, here are some web thread discussing on this:

    #Preventing Duplicate Record Insertion on Page Refresh
    http://aspalliance.com/687

    #Prevent Duplicate Form Posting
    http://forums.asp.net/p/447620/471229.aspx#471229

    http://forums.asp.net/p/1190997/2045619.aspx

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.


    --------------------
    >From: =?Utf-8?B?QXNhZg==?= <>
    >References: <>

    <>
    >Subject: RE: Prevent ASP.NET page to resend data on refresh?
    >Date: Wed, 12 Dec 2007 08:31:03 -0800
    >
    >Hi Peter,
    >
    >I misunderstood your solution, will be much appreciated if you can post an
    >example.
    >
    >Asaf
    >
    >"Peter Bromberg [C# MVP]" wrote:
    >
    >> One easy way to handle this is to set a Session variable the first time

    the
    >> page is posted. You can check for the presence of this on any refresh

    and
    >> abort resending.
    >> -- Peter
    >> Site: http://www.eggheadcafe.com
    >> UnBlog: http://petesbloggerama.blogspot.com
    >> MetaFinder: http://www.blogmetafinder.com
    >>
    >>
    >> "Asaf" wrote:
    >>
    >> > Hi,
    >> >
    >> > How can I prevent from an ASP.NET page to resend all the data again

    when the
    >> > user press the Refresh button or F5 on the browser?
    >> >
    >> > Thanks in advanced,
    >> > Asaf
    >> >

    >
    Steven Cheng[MSFT], Dec 13, 2007
    #5
  6. Asaf

    elizas Guest

    One of most common issue which many of the web developers face in their web
    applications, is that the duplicate records are inserted to the Database on
    page refresh. If the web page contains some text box and a button to submit
    the textbox data to the database. In that case when the user insert some data
    to the textbox and click on the submit button, it will save the record to the
    Database and then if the user refresh the web page immediately then the same
    record is again saved to the database as there is no unique keys that can be
    used to verify the existence of the data, so as to prevent the multiple
    insertion.

    http://www.mindfiresolutions.com/Avoid-Duplicate-record-insertion-on-page-refresh-in-ASPNET-486.php
    elizas, Feb 15, 2010
    #6
    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. mrby
    Replies:
    6
    Views:
    866
    GaryM
    May 6, 2004
  2. widjay

    resend a message

    widjay, Apr 4, 2005, in forum: Java
    Replies:
    0
    Views:
    369
    widjay
    Apr 4, 2005
  3. =?Utf-8?B?RXdhbiBGYWlyd2VhdGhlcg==?=

    [RESEND] Need to remove blank XMLNS attribute from xmldocument

    =?Utf-8?B?RXdhbiBGYWlyd2VhdGhlcg==?=, Apr 18, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    4,020
    Martin Honnen
    Apr 18, 2006
  4. Stylus Studio
    Replies:
    0
    Views:
    371
    Stylus Studio
    Sep 6, 2005
  5. Robert D. Young
    Replies:
    0
    Views:
    276
    Robert D. Young
    Aug 21, 2003
Loading...

Share This Page