Submission formats
Redirect after a successful POST
Return a redirect after changing server state so refreshing the result page does not submit the same form again.
8 minute lesson
After a successful POST, redirect to a GET page. This is often called the Post/Redirect/Get pattern.
Imagine a form that creates a support request:
POST /support/requests
The server validates the fields, creates request 842, then responds:
HTTP/1.1 303 See Other
Location: /support/requests/842
The browser follows with:
GET /support/requests/842
The address bar now contains the result URL. Refreshing repeats the GET instead of asking to repeat the POST. The result can also be bookmarked or shared if access rules allow it.
Redirect only after the change succeeds. When validation fails, return the form with field errors and a suitable non-success status. Redirecting errors often throws away the submitted values and messages unless you store them elsewhere.
A 303 See Other explicitly tells the client to retrieve the location with GET. Other redirect statuses have different method rules, so choose deliberately.
The server must still handle duplicate POST requests safely. A person can double-click, retry after a timeout, or resend the request outside the browser. A redirect improves navigation; it is not duplicate protection.
Submit the form, inspect the POST and following GET in the Network panel, then refresh the result page. Confirm no second record is created.
Lesson completed