The project repeatedly adds an identical record to the database after refreshing. Cause error. The problem is as follows:
How does Asp.net prevent repeated data submission problems caused by PAGE refresh or rollback?:
In fact, Asp.net's prevention of refresh is a common problem in Asp.net development. There are usually many ways to achieve it: (the following are some solutions) not very comprehensive, and I hope my friends can add more. Thank you.
1.Request forwarding(After performing the update operation in the database, jump to another page immediately to prevent the page from refreshing and sending back ),
2.Reload the page(Use JavaScript to re-load the page after the operation is executed: <SCRIPT> window. Location = "Current page '</SCRIPT>)
3.Do not save Cache(That is, after the submission, the data in the form will not be cached and saved by the browser. If a refresh or backend request is received, the page will be displayed as "the webpage has expired ", the data will not be submitted repeatedly, which will prevent repeated submission refresh.
(See: http://www.cnblogs.com/zpq521/archive/2007/08/14/854631.html ))
4.A solution of msdn: It re-defines the system. web. UI. when a page class is used to load a page, it is a "refresh", "back" request, or a normal request. Other pages inherit the custom page class.
(See:Http://msdn.microsoft.com/zh-cn/library/ms379557 (vs.80). aspx)
Of course there may be other solutions,I hope my friends can propose their own solutions. Thank you.