Chrome history bug maybe - doing PRG, and when nav

2019-06-17 06:09发布

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.

1条回答
Anthone
2楼-- · 2019-06-17 07:09

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

查看更多
登录 后发表回答