Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
78
rated 0 times [  80] [ 2]  / answers: 1 / hits: 47580  / 11 Years ago, thu, july 18, 2013, 12:00:00

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?


More From » asp.net

 Answers
6

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.


[#76900] Wednesday, July 17, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
susand

Total Points: 690
Total Questions: 101
Total Answers: 104

Location: Lesotho
Member since Wed, Jun 2, 2021
3 Years ago
;