在不丢失视图状态的情况下防止浏览器刷新时重新提交网络表单 [英] Preventing webform resubmission on browser refresh without losing viewstate

查看:22
本文介绍了在不丢失视图状态的情况下防止浏览器刷新时重新提交网络表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

重复: 当浏览器重新加载/返回时,如何防止再次写入数据库?

如果用户从浏览器请求刷新,是否有一种优雅的方式来阻止 .aspx 页面重新提交表单数据?

Is there a nice elegant way to stop an .aspx page from resubmitting form data if the user requests a refresh from their browser?

理想情况下不会丢失视图状态.

Ideally without losing the viewstate.

对我来说最优雅的解决方案是将相关控件包装在 asp.net ajax UpdatePanel 中.给大家.

The most elegant solution for me turned out to be wrapping the relevant controls in an asp.net ajax UpdatePanel. Ta everyone.

推荐答案

没有优雅的方式,但有选择.如其他答案之一所述,您可以执行 HTTP 重定向响应.另一种解决方案是通过 Ajax 或 iframe 等方式提交.

There is no elegant way, but there are options. As stated in one of the other answers you can do a HTTP redirect response. Another solution is submitting through means such as Ajax, or through an iframe.

这篇关于在不丢失视图状态的情况下防止浏览器刷新时重新提交网络表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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