使用后退按钮导航时,在浏览器中自动重新发送POST请求 [英] Automatically resend POST request in browser when navigating using back button

查看:178
本文介绍了使用后退按钮导航时,在浏览器中自动重新发送POST请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我点击浏览器的后退按钮时,会弹出一个消息,询问我是否要重新发送请求或重试。我试图找出如何避免这个消息显示,当用户导航回到任何页面使用浏览器后退按钮。基本上,我希望浏览器在重新发送请求之前不要求确认。

现在,当在Firefox中测试时,我得到了这个结果:



单据已过期
此单据不再可用。所请求的文档在Firefox的缓存中不可用。为安全起见,Firefox不会自动重新请求敏感文档。请再次尝试重新从网站请求文档。

$ b

解决方案

听起来就像您与之交互的系统不遵循Post / Redirect / Get模式。


  1. 客户端向服务器发出 POST 请求,
  2. 数据和

  3. 将客户端重定向到客户端使用的另一个URL

  4. GET

通过这种方式,客户端可以重新加载最后的URL或使用后退按钮,而不会使用 POST



请参阅维基百科了解详情。


When I click the back button of a browser, a message pops up asking if I want to re-send the request or Try Again. I am trying to find out how to avoid this message displaying when a user navigates back to any page using the browser back button. Basically, I want the browser not to ask for a confirmation before resending the request.

Right now, when testing in Firefox, I get this:

Document Expired This document is no longer available. The requested document is not available in Firefox's cache. As a security precaution, Firefox does not automatically re-request sensitive documents.Click Try Again to re-request the document from the website.

解决方案

Sounds like the system you interact with doesn't follow the Post/Redirect/Get pattern.

  1. The client issues a POST request to the server,
  2. the server does something with the data and,
  3. redirects the client to a different URL
  4. which the client uses GET to fetch.

This way the client can reload the last URL or use the back-button and will not use POST again.

See Wikipedia for details.

这篇关于使用后退按钮导航时,在浏览器中自动重新发送POST请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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