Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

The cause of resubmit form in browser

I am newbie of backend developer. I am learning PRG (post redirect get) pattern to prevent the resubmit form when user click reload button after submitting the form. I don’t understand why click reload button after submitting form cause resubmitting again.Please, tell me the causes of that problem.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

When you submit a form with method="POST", the browser constructs a POST request and sends it to the server. If the server responds with 200 OK and an HTML document then the browser will render that HTML document.

The refresh button is a browser feature which lets the user repeat the last request.

Since the last request, in the above scenario, is "a POST request", it causes the browser to repeat the POST request.


In the PRG pattern, the response to the POST request is a redirect which causes the browser to make a GET request.

In this scenario, the the request is "a GET request".

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading