Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

browser

post

get

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?

like image 344
xport Avatar asked Dec 28 '22 03:12

xport


1 Answers

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

like image 158
Tr1stan Avatar answered Jan 14 '23 04:01

Tr1stan