Heres the scenario – using asp.net MVC with jquery mobile – newbie on both
Problem: Back button sends a GET to a page that was created with a POST
Scenario:
- Page 1 has a searchbox and submit button – clck submit does POST to page 2.
- Page 2 has list of serch result links, click a search result, go to page 3
- Click back button on page 3, and it sends a GET to page 2.
Tried on Safari and Firefox. Firebug showing a GET on the back button.
Is this common? How would you deal with this?
A) When submitting form, somehow add the textbox to the URL (sounds tricky)
B) Mark the search page action with both HTTPPost and HTTPGet? Then save the search text in a session or somewhere?
C) Is there a better option?
Any advice appreciated!
I think may have approached this the wrong way. In general, POST should be used for requests that potentially modify state (update database etc) on the server, and GET should be used for read-only operations.
In this case it is a read only action therefore a HTTP Get is the correct http verb to use. Assuming you are using Razor your form action would look like