Preventing webform resubmission on browser refresh without losing viewstate(在不丢失视图状态的情况下防止浏览器刷新时重新提交网络表单)
问题描述
重复: 当浏览器重新加载/返回时,如何防止再次写入数据库?
如果用户从浏览器请求刷新,是否有一种优雅的方式来阻止 .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.
这篇关于在不丢失视图状态的情况下防止浏览器刷新时重新提交网络表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在不丢失视图状态的情况下防止浏览器刷新时重
基础教程推荐
- 获取C#保存对话框的文件路径 2022-01-01
- 将数据集转换为列表 2022-01-01
- 如果条件可以为空 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
