0

We have a survey web app that randomly inserts duplicate survey records after user completes survey.

I tried to fix the problem by redirecting to a confirmation.aspx page, and therefore the survey page doesn't get reposted when user hits F5. That fix worked.

However, we have noted that duplicate records are still getting in, sometimes 20 minutes apart, sometimes a minute.

If you click on the Back Button, the confirmation page won't let the user go back, so it will just post the confirmation page back.

Here's an example of the duplicate records:

CustomerSurveyID    CustURL SurveyType  SentDate    SubscriberID    ResponseDate    CustomerID
2665    http://survey.xxx.com/ConsumerSurvey.aspx?17157&281600783&2&2014-05-27T00:00:00 2   2014-05-27 00:00:00.000 17157   2014-05-29 16:36:41.787 281600783
2666    http://survey.xxx.com/ConsumerSurvey.aspx?17157&281600783&2&2014-05-27T00:00:00 2   2014-05-27 00:00:00.000 17157   2014-05-29 16:37:08.027 281600783

We have no idea what the end user could be doing to cause this duplicates to get inserted in the database. Is there a reason that could be happening?

1
  • 1
    You will need to provide at least some code. How are you saving your data? Commented May 30, 2014 at 18:06

4 Answers 4

1

40-Love I would direct you to this excellent article. As you will see, there are several options for your problem. All solutions are discussed here. I recommend using two,

Response.Redirect(Request.Url.ToString(), false) 

And Sql exceptions to trap duplicates. this may require changes to your database.

http://aspalliance.com/articleViewer.aspx?aId=687&pId=-1

Sign up to request clarification or add additional context in comments.

Comments

1

What i am guessing is that user is clicking back button and again inserting the record that's why you may be getting duplicate record.

My suggestion is that:-

1)Once the user insert the record reset all the controls value to blank,so that if he/she again try to click the insert button,duplicate entry is avoided. 2)And on the page_load event call one reset() function which will reset all the controls value to their defaults.

Comments

1

It would help if you provided code to show when the data gets inserted into the database within your flow. Without seeing your code, I'll assume there is some reason you need to stay on the same page and not redirect to a confirmation page or something of that nature upon the form submission. Redirection would be the simplest solution. If that's not possible, make sure your code that inserts the data is inside a block that checks whether the page is being rendered for the first time.

if(!isPostback())
{
    /*Database Handling Code Here*/
}

Comments

0

The problem was they had two browser windows open at the same time, and they were hitting the Finish button on two different windows, thus inserting twice.

In this case, Response.Redirect was not effective.

The solution in this case was to create an unique index in the table that was being updated.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.