Post-redirect-get pattern

When you submit a form that will update data in an application, it is best to configure the form to post the data. Often you will then forward the request on to some code that will display the result. However, if you then refresh the page, you will get a confusing error like this:

Repost error.

If you click on "Retry", the browser will re-post the data, which may cause an error or may result in a problem like a duplicated order.

One useful way round this is for the server to redirect to a results page instead of forwarding. When the server tells the browser to redirect to a new URL, the browser does a get for the new URL. The posted URL is forgotten, so if the refresh button is subsequently clicked, the get is resent. This means that the data from the form is not posted twice and unhelpful errors are not displayed to the user.