当我preSS浏览器后退按钮会发生什么? [英] What happens when I press browser BACK button?

查看:98
本文介绍了当我preSS浏览器后退按钮会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑方案:


  1. 我参观了使用ASP.NET建立了一个网站的页面。该网页是包含ASP.NET服务器控件一个简单的aspx页面。

  1. I visited a page of a website built using ASP.NET. The page is a simple aspx page containing ASP.NET server controls.

我点击它带我到同一网站上的其他一些网页中的链接。

I clicked on a link which takes me to some other page on the same website.

我点击<大骨节病>返回浏览器的按钮。

:在页面生命周期的角度会发生什么?是否所有的事件发生或浏览器只显示页面的缓存版本未做任何要求吗?

QUESTION: What happens in terms of page life cycle? Does all the events occur or the browser just displays the cached version of the page without making any requests?

推荐答案

我认为最好的答案是:这取决于浏览器,尤其是后/回发后

I think the best answer is: It depends on the browser, especially after a post/postback.

用一个确认对话框弹出来的效果旧的浏览器的页面中包含将被重新提交POST数据,你既可以进行(重新提交),或抵消。因为这发生在ASP.NET的WebForms一切都是 FORM 元素(ViewState中,事件等)的一部分,这会导致要重复的整个生命周期。

Older browsers used to pop up a confirmation dialog to the effect of "the page contains POST data which will be resubmitted", and you could either proceed (resubmit) or cancel out. Since everything that happens in ASP.NET WebForms is part of the FORM element (ViewState, events, etc.), this would cause the entire lifecycle to be repeated.

当然,这没有造成与重复提交后患无穷,所以很多网站不得不想出解决方法的问题,欺骗,今天大多数的浏览器刚刚从缓存中,而不是抓取网页。

Of course, this caused no end of trouble with duplicate submissions, so many sites had to come up with workarounds for the dupe problem, and today most browsers just fetch the page from cache instead.

...这就是除非您覆盖缓存控制头和强制浏览器而不是网页保存在缓存中。显然,在这种情况下,不能从高速缓存中检索,所以它通常会结束被重新提交。但同样,这取决于浏览器 - 例如,一些浏览器将不允许通过SSL重新提交,因此,如果这是在使用的协议,那么用户只会看到一条消息,称该页面已过期/不能图所示。

...That is unless you override the cache-control headers and force the browser not to store the page in cache. Obviously, in that case, it can't be retrieved from cache, so it will usually end up being resubmitted. But, again, it depends on the browser - for example, some browsers won't allow the resubmission over SSL, so if that's the protocol in use then the user will just see a message saying that the page has expired / can't be shown.

试想想起来了,可能是一个更好的答案是:作为一个网站设计者,你真的不能单击后退按钮时,依赖于从用户的浏览器的特定行为。如果重复提交可能产生负面的副作用(如充电信用卡两次),那么你就需要采取适当的措施,以prevent这种情况的发生。这是很好的做法无论如何,因为它是完全可能的,用户只需意外双击提交按钮。

Come to think of it, probably an even better answer is: As a site designer, you really can't depend on any specific behaviour from the user's browser when the Back button is clicked. If a duplicate submission could have negative side-effects (such as charging a credit card twice), then you need to take adequate measures to prevent that from happening. It's good practice anyway as it's entirely possible for a user to simply double-click the "submit" button by accident.

这篇关于当我preSS浏览器后退按钮会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆