1

I have a big problem but easy for you, which I had to solve before and now I dont have any more options than fix it. Here's what I got:

If i send data to the DataBase, everything works great but if in some case the user decide to reupload the page, the same information that was send before send again and the database will save it. How can I avoid this? I dont want whenever the page reupload the information send again, and again and again! it'll be a disaster!

Thanks for help!

Misters
  • 1,337
  • 2
  • 16
  • 29
  • What do you have currently..? it may be easier to show some code so others whom may choose to answer / help you can see what it is you are doing logically speaking. you could write some SQL Logic as well that will check if Record Exist already which means that you will have to do some Session tracking and or come up with your own type of Delta but will be able to advise more once the code is shown.. – MethodMan Mar 09 '13 at 20:37
  • 1
    There is all ready many articles on the same subject. http://stackoverflow.com/questions/5381162/post-redirect-get-with-asp-net http://www.codeproject.com/Articles/68371/Detecting-Refresh-or-Postback-in-ASP-NET – Aristos Mar 09 '13 at 20:37
  • I can think of 3 solutions easily, but without the code involving your postback handling and database call, it's hard to help you. – Mike C. Mar 09 '13 at 20:53
  • actually thats the whole code, its just a button that saves the information taken from a textbox in the database. And thats all. – Misters Mar 09 '13 at 21:09

1 Answers1

1

What you need to do is use the Post/Redirect/Get pattern:

http://en.wikipedia.org/wiki/Post/Redirect/Get

This pattern solves your problem exactly.

Basically, right after the database is updated, redirect the user to some other page (with a message such as "Updated successfully!").

Yehuda Shapira
  • 8,460
  • 5
  • 44
  • 66