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

隐身守侯 提交于 2019-12-10 12:57:11

问题


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:


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



来源:https://stackoverflow.com/questions/9909850/chrome-history-bug-maybe-doing-prg-and-when-navigating-again-to-the-same-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!