tags:

views:

112

answers:

2

How can I avoid to submit again the form when I hit refresh of the browser? Thank you.

A: 

When a user first visits a form, create them a GUID (or other token that you can uniquely identify a specific user request) and send that through their entire journey on the form. When you commit to the database, add this to a field in there too. A quick check beforehand to see if it already exists and you're sorted. :)

Edit: These ways are not so much specific to when the user "hit[s] refresh on the browser", more as a way of stopping accidental duplicate entries anyway. As far as other useful threads, this question asks and gets a few good replies.

Amadiere
+5  A: 

Have a look at the Post/Redirect/Get pattern, and the following article:

http://www.theserverside.com/tt/articles/article.tss?l=RedirectAfterPost

From the above link:

PRG pattern can be rephrased like this:

  • Never show pages in response to POST
  • Always load pages using GET
  • Navigate from POST to GET using REDIRECT
karim79