Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

To display the webpage again, Internet Explorer needs to resend

In my ASP.NET WebForms page I have a Modal window that pops up. The javascript code for displaying this modal window is as follows:

function OpenMailAddressWin(subscriberContactRelationGid, routeId, btn) {
    window.showModalDialog("SubscriberSecondaryAddress.aspx" + BuildQueryStringValuesForSubscriber(subscriberContactRelationGid, routeId, returntxtReceiptDate().value), this, strWindowFeatures + ";scroll:no;dialogWidth:442px;dialogHeight:350px");
    location.reload(true);
}

After the modal window is closed I need to refresh the parent page (hence the location.reload(true); statement at the end) in order for alterations made in the modal window to take affect.

Now the thing is that sometimes (not every time, infuriatingly) when I close this modal window I get a warning popup which says:

" To display the webpage again, Internet Explorer needs to resend the information you've recently submitted.

If you were making a purchase, you should click Cancel to avoid a duplicate transaction. Otherwise, click Retry to display the webpage again."

Any ideas why this is happening?

like image 772
Sperick Avatar asked Jul 18 '13 12:07

Sperick


1 Answers

This is the double-submit problem in browsers.

When a page is loaded using POST request and you try to reload the page using location.reload(true);, the browser needs to send another POST request to the server and this may cause problems as POST is supposed to change state on the server. Therefore, the browser needs confirmation from the user. To solve this problem, we usually use POST-REDIRECT-GET pattern.

In your case, just simply using location.href = location.href should solve the problem as this will reload the page using GET.

like image 128
Khanh TO Avatar answered Sep 16 '22 13:09

Khanh TO