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.
这篇关于在不丢失视图状态的情况下防止浏览器刷新时重新提交网络表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在不丢失视图状态的情况下防止浏览器刷新时重
基础教程推荐
- 全局 ASAX - 获取服务器名称 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
