Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome history bug maybe - doing PRG, and when navigating again to the same form - no history entry is added

There is a strange back button behavior occurring only in Chrome.
I have two pages - Grid and a Form
the scenario:
1. When navigating from the Grid to the Form everything is fine - the Grid is added to the history.
2. When the Form is sent to the server via post, i use RedirectToAction to redirect(302) to the Grid again - the Form is added to the history.
3. When navigating again from the Grid to the Form after the redirect, a history point containing the Grid address is not added to the history

Now you have to click twice on the back button to get back to the grid.

if you repeat all the steps several times and watch the history stack you will see a sad list of Form entries without the Grid in the middle

edit: here is a link to a page demonstrating the problem, open it in chrome and follow the instructions - see the Chrome history bug in action

The only "Solution" i found for this is putting some random crap in the link to the Form, but i really hate this.

like image 316
Avi Pinto Avatar asked Mar 28 '12 14:03

Avi Pinto


1 Answers

Chrome is strict about using HTTP 303 See other while your application uses 302 Found for redirects. See a related chrome bug report here: http://code.google.com/p/chromium/issues/detail?id=2801

You can vote to fix ASP.Net MVC's RedirectToAction here: http://connect.microsoft.com/VisualStudio/feedback/details/706961/asp-net-mvc-controller-redirecttoaction-method-should-return-http-303-response

like image 190
Udi Avatar answered Sep 23 '22 20:09

Udi