ASP.NET 3.5后退按钮控件/刷新控件(从未找到有效的解决方案)
您好,感谢您抽出时间。
我花了相当多的时间来寻找一个老问题的答案,即当用户向后、向前或刷新页面时防止重复的帖子。 我已经看到了很多提出的解决方案,但没有一个有效。
建议的解决方案#1)许多人提供了指示浏览器不缓存页面的方法,包括我拥有的一些书籍。 人们经常注意到,这实际上并不是一个好的解决方案,因为用户可以在浏览器中关闭此功能,导致浏览器不接受请求。
建议的解决方案#2)在一本书中,我建议使用 Viewstate 和 Session 中设置的时间戳可以检测陈旧页面。 此检测确实有效,但“该怎么办”部分不起作用:重定向到同一页面,从而以原始状态重新加载页面。
我没有发布任何代码,因为我刚刚绕了很多版本。
这是我第一次访问该网站,希望我能找到一些很棒的建议:)
再次感谢您的宝贵时间。
Hello and thanks for your time.
I've spent quite a bit of time searching for an answer to the old question of preventing duplicate posts when the user navigates back, forward, or refreshes the page. I've seen quite a few solutions proposed, none of which are working.
Proposed solution #1) Many people offer ways to instruct the browser to not cache pages, including some books I have. It is often noted that this isn't really a good solution because the user can turn off this feature in their browser, causing it to not honor the request.
Proposed solution #2) In a book I have it proposes that using timestamps set in the Viewstate and Session can detect stale pages. This detection DOES work, but the 'what to do about it' part does not: redirect to the same page, thereby reloading a page in it's pristine state.
I haven't posted any code because I've just gone in circles with many versions.
This is my first visit to this site and hopefully I can find some wonderful advice :)
Again, thank you for your time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现有效的解决方案是在页面上放置一个隐藏控件,其中包含 GUID 值。 将 GUID 保存到数据库记录中,然后每次用户提交数据时,在处理数据之前确保 GUID 是唯一的。
A solution I have found to be effective is to place a hidden control on the page with GUID value inside. Save the GUID to your database record and then every time the user submits data, make sure the GUID is unique before processing the data.