Pages

Saturday, March 16, 2013

You should always issue a redirect for successful POST requests


The reason: if a user hits “Refresh” on a page that was loaded via POST, that request will be repeated. This can often lead to undesired behavior, such as a duplicate record being added to the database – or, in our example, the e-mail being sent twice. If the user is redirected to another page after the POST, then there’s no chance of repeating the request.
You should always issue a redirect for successful POST requests. It’s a Web development best practice.

No comments:

Post a Comment