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

1

7

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.

Sawyers answered 28/3, 2012 at 14:40 Comment(3)
I'm also almost sure it isn't related to the server technology i use. It is related to the redirect with 302 from the server and then returning to the same Url. added the MVC part to give context, guess it will happen using RoR as well..Sawyers
Can you setup a small example website for reproducing?Jackstraw
I will try to put something, now its deep in my appSawyers
J
3

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

Jackstraw answered 2/4, 2012 at 5:29 Comment(3)
Amazing how long lived this bug lives. alas returning 303 doesn't solve the chrome issueSawyers
will add the 303 to the example page, didn't accept your answer because it didn't solve the chrome problem and leaving it open might draw more attention to the problem(so +1 and thanks for your help)Sawyers
now added another link to the example page to a form that will post and then redirect with 303Sawyers

© 2022 - 2024 — McMap. All rights reserved.