I am working currently on an ASP.NET MVC4 web application and currently working on how I can prevent the users from inserting duplicate entries in the db , when a user submits an entry and then again presses the back button and submits the same data again. I know this can be achieved by Stored procedures in db but I want to implement this concept using the output caching feature. Can you please suggest whether this approach would be feasible and scalable and also the steps I need to take to implement this .
Asked
Active
Viewed 275 times
1 Answers
1
I know this can be achieved by Stored procedures in db
Why so complicated? Simply put an unique constraint on the columns that you don't want to be duplicated and then when inserting a record catch the corresponding SqlException
which contain a number indicating that an unique constraint has been violated
due to duplicate insert.

Community
- 1
- 1

Darin Dimitrov
- 1,023,142
- 271
- 3,287
- 2,928
-
Yes I know that can be achieved easily.. but I am also keen on finding whether we can achieve this functionality using the outputcaching attribute – Vineet Mar 06 '13 at 08:30