ASP. NET prevents duplicate commits due to page refresh or rewind

Source: Internet
Author: User
Tags rewind

The project often encountered after the refresh of repeated to the database to add an identical record, resulting in duplication of data, how to circumvent these problems? Let's talk about how ASP can prevent the page from flushing or backing back from recurring data issues:

In fact, ASP. NET prevent refresh is a common problem in ASP. There are often several ways to do this: (The following are just some of the methods of personal summary), but also hope that friends can add a lot. Thank you.

1: Request Forwarding (that is, jump to another page immediately after the data commit operation to prevent the page refresh from causing the postback operation)

2: Do not save cache Response.Cache.SetNoStore (); (That is, the data on the form after submission is not saved by the browser's cache, if you encounter a refresh or back-up request at this time, it will show "page has expired", the data will not be repeated, this has prevented the refresh of duplicate submissions effect.)

A solution for 3:MSDN: It is when the page is loaded by redefining the System.Web.UI.Page class, is it a "refresh", "back" request, or a normal request, and the other pages inherit the custom page class

(See also: http://msdn.microsoft.com/zh-cn/library/ms379557 (vs.80). aspx)

Of course, there are other solutions, I hope friends to put forward their own solutions. Thank you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.