The idea is that you create a unique number for the form, and when you submit the form, you save this unique number in the database in the record that you are editing / creating. Before saving, you check whether this number has already been used, in this case it is a form that was resubmitted during the update.
If you are updating a record, you only need to check if this record has been saved with the same unique number, but if you are adding a new record, you need to check if any other record has this number.
A Guid is a good amount to use, as it is unlikely that you will get a duplicate. The 31-bit random number that the Random class can create is also unlikely to produce duplicates, but 128 bits of Guid make it much more unlikely.
You do not need to create a Guid value in the database, just use Guid.NewGuid() in the code that initializes the form. You can put Guid in a hidden field on the form. In the database, you only need a field in which you can store the Guid value, or a Guid data type, if available, or just a text field large enough to store the Guid text view.
You can use the ToString method to get a string representation of the Guid value (so you can put it on the form). Using id.ToString("N") gives the most compact format, i.e. 32 hexadecimal digits without separators. Using id.ToString("B") gives the more recognizable format "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}". To return a Guid from a string (of any format), you simply use new Guid(str) .
source share