Clicking Refresh Button Resubmits Form

Discussion in 'ASP .Net' started by Nathan Sokalski, Sep 17, 2005.

  1. I have a form that submits data to a database. If I click the browser's
    refresh button after submitting the form once, the form is submitted a
    second time. How can I avoid this problem? Thanks.
     
    Nathan Sokalski, Sep 17, 2005
    #1
    1. Advertisements

  2. Nathan,

    You could send the results page a response.redirect or go to a different
    page with a meta refresh. Either way, you need to get the client machine to
    a page that wasn't produced by submitting form data. So the logic would be:

    Client posts form data on submit.

    Server processes data and stores results for future display (if necessary)
    in a session variable or elswhere.

    Server sends client as the result of the form post a redirect or meta
    refresh which sends client to a new page that wasn't produced via posted
    data.

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche
     
    S. Justin Gengo, Sep 17, 2005
    #2
    1. Advertisements

  3. Nathan Sokalski

    Phil G. Guest

    Would the Page.IsPostback work for you?

    Rgs, Phil
     
    Phil G., Sep 17, 2005
    #3
  4. I tried the Page.IsPostback() and it doesn't help. If I use the condition
    Not Page.IsPostback() then I can't submit at all, and if I use
    Page.IsPostback() it still gives me the resubmitting problem with the
    refresh button.
     
    Nathan Sokalski, Sep 18, 2005
    #4
  5. Nathan,

    Any reason why you have the newsgroup AdoNet in this crossposting. In other
    words, with what can we help you that is AdoNet related?

    Cor
     
    Cor Ligthert [MVP], Sep 18, 2005
    #5
  6. Nathan Sokalski

    Joerg Jooss Guest

    This will not work, as refresh resends the last request. A POST thus
    stays a POST...

    Cheers,
     
    Joerg Jooss, Sep 18, 2005
    #6
  7. Eliyahu Goldin, Sep 18, 2005
    #7
  8. Patrick.O.Ige, Sep 19, 2005
    #8
  9. use Redirect to give output that means with redirect the output page
    will be different and now postback will not be there
     
    Deepak Dhawan, Sep 21, 2005
    #9
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.