页面刷新问题(F5) [英] Page Refresh Issue (F5)
问题描述
我有一个页面上只有一个文本框,上面有评论和发表评论按钮.
I have a page on which i have only one TextBox say Comments and Post Comment Button.
现在,在输入用户期间,在注释"文本框中输入内容,然后按发布注释"按钮.无论文本框中的内容是什么,所有内容都会存储在数据库中,并且我用
Now during input user write something in Comments textbox and press Post Comment button. Whatever is written in the textbox all get stored in database and i clear the textbox with
textbox.text = string.empty statement.
此用户不执行任何操作后按F5键,我已经清除的相同注释将再次存储在数据库中.我想跟踪此事件,即在F5上触发按钮事件时不应执行任何操作.请帮忙.
After this user press F5 without doing anything and the same comment which i have already cleared gets stored in the database again. I want to keep track of this thing that when button event is fired on F5 should not do anything. please help in this.
推荐答案
您可能想阅读发布/重定向/获取模式.
执行数据库提交后,您需要将重定向发送回用户,这会导致浏览器发出第二个请求,并且消除了刷新刷新浏览器后重复发回邮件的可能性.重定向URL可以是您开始时注意到的其中一个要求的页面.
After performing the database submission you need to send a redirect back to the user which causes the browser to make a second request and eliminates the possibility of a duplicate post back if they refresh the browser. The redirect URL can be the same page you started on which you noted is one of the requirements.
这篇关于页面刷新问题(F5)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!