To display the webpage again, Internet Explorer needs to resend
This occurs when you try to return view(Model)
from your POST request. Actually you cannot return a view from POST request because returning a view is supposed to be a GET operation and it must be done under GET request.
So after posting your data successfully and saving the data in database , you have to use ReturnToAction
in your controller and return your final view from that action method.
Also If you want to refresh your page, you must use location.href = location.href
instead of window.reload()
, because location.href
will get the data through GET request.
You can create a setTimeout
function like this.
This will not give you any
setTimeout(function () {
window.parent.location.reload();
}, 100);
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.