Allowing users to Refresh browser without the Confirm Form Resubmission pop-up
After processing the POST page, redirect the user to the same page.
On http://test.com/test.php
header('Location: http://test.com/test.php');
This will get rid of the box, as refreshing the page will not resubmit the data.
How to get Confirm form resubmission when user trying to refresh browser
To refresh without getting the prompt the page must have been fetched using HTTP GET
Make the form have method="GET"
instead of method="POST"
(and fix server processes to work with this change as apropriate)
Alternatively cache the post data in a session and redirect to the display page using HTTP code 303
immediately after form submission.
If you want to cause the prompt, make the link that takes the user to the page into a submit button on a POST form. if a user arrives with a GET request have serve them a page having javascript that submits a form converting the request into a POST request.
How to prevent form resubmission when page is refreshed (F5 / CTRL+R)
Use the Post/Redirect/Get pattern. http://en.wikipedia.org/wiki/Post/Redirect/Get
With my website, I will store a message in a cookie or session, redirect after the post, read the cookie/session, and then clear the value of that session or cookie variable.
Web Browser display a warning 'Confirm Form Resubmission' when user press F5 or refresh the page
When PageIndex
is clicked, it postbacks the page, i.e. equivalent to form submission. So when you refresh
, it agains posts page, and asks Confirm Form Re-submission
.
This is equivalent to this scenario. -- Preventing form resubmission
Submit a form, and after submission , refresh the page, it will ask same message. And this is the default behavior of browser.
It has nothing to do with your grid paging or the paging click in it. It gets' fired by the browser to prevent the user from repeating the form submission as it posts entire grid data.
Preventing form resubmission
There are 2 approaches people used to take here:
Method 1: Use AJAX + Redirect
This way you post your form in the background using JQuery or something similar to Page2, while the user still sees page1 displayed. Upon successful posting, you redirect the browser to Page2.
Method 2: Post + Redirect to self
This is a common technique on forums. Form on Page1 posts the data to Page2, Page2 processes the data and does what needs to be done, and then it does a HTTP redirect on itself. This way the last "action" the browser remembers is a simple GET on page2, so the form is not being resubmitted upon F5.
How to Reload/Refresh page in IE browsers without pop-up of form resubmission using JS
If there was any form data posted on the referring page then you will always get that popup when you do a page refresh. What you can do instead is set the page location to the current page location, which has a similar effect but is not a page refresh...
window.location.href = window.location.href;
Prompted for Confirm Form Resubmission on refreshes after postback. What am I doing incorrectly?
When you refresh the browser, it will resend the last request you did. If it was a POST request (like you do in case of postback) then it will re-post the information but before doing it you'll see the warning message you describe.
The best way to avoid this problem is implementing the pattern Post/Redirect/Get
Post/Redirect/Get (PRG) is a common design pattern for web developers to help avoid certain duplicate form submissions and allow user agents to behave more intuitively with bookmarks and the refresh button.
Normally people don't implement this (although we should) unless the re-post may cause some data inconsistency.
Related Topics
How to Remove All Numbers from String
Create Superglobal Variables in PHP
Php: Fopen() Permission Denied
Php/Gd - Transparent Background
Confusion Between Bindvalue() and Bindparam()
How to Put My Wamp Online for Someone to Access
How to Validate Phone Number Using PHP
Regex - How to Insert String Before File Extension
Codeigniter 2 on Iis with Web.Config File
How to Check If a Longitude/Latitude Point Is Within a Range of Coordinates
Check If a File Was Included or Loaded
How to Find Annotations in a PHP5 Object
If You Create a Variable Inside a If Statement Is It Available Outside the If Statement
Extending Sonata User Bundle and Adding New Fields
PHP Check If Time Is Between Two Times Regardless of Date