Refreshing a page in a browser yields POST or GET request?

笑着哭i 提交于 2019-12-10 20:10:20

问题


I am learning asp.net mvc form processing now and confused with the following:

What happens if we push the refresh button on the browser? It makes a POST or GET request?


回答1:


This is dependant on the last call that was made by the browser to get the current data. Eg:

a) If you submitted a form, performing a POST and then hit refresh, the browser will do another POST.

b) If you just clicked a link that took you to another page, performing a GET, you'll a refresh will perform a get.

If you're just starting out understanding the GET/POST methods, there is a nice pattern that you should understand that will help you not get in situations where data is posted again and again by users who constantly refresh the browser after a POST:

http://en.wikipedia.org/wiki/Post/Redirect/Get

and

An example specifically for asp.net MVC




回答2:


Whatever HTTP method was used to generate the page will be repeated when you hit refresh.

If you're using <% Html.BeginForm(...) %> when the form is submitted, it will create a POST, and if the resulting page is refreshed, it will repeat the POST.



来源:https://stackoverflow.com/questions/4497643/refreshing-a-page-in-a-browser-yields-post-or-get-request

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!