Reputation: 1037
Im implementing Web Form using ASP.NET in c#, I have a page with few TextBox and a Submit Button, the data from TextBox going to insert into Database when Submit Button is pressed, the page will be retain and no redirect is required.
However, there is a issue after the data has been submitted, if F5/refresh the page without click on the Submit Button, the data will insert again and again.
How can I avoid such issue happen after the first submission?
Thank you in advanced.
Upvotes: 1
Views: 1388
Reputation: 206
Unfortunately you can't prevent something like that because the browser excute the same code again after you press refresh so thier is nothing you can do there but you can use response.redirect to the same page again.
Also you can check for duplication in the database so if that record exist don't save it again.
Hope I Helped
Upvotes: -1
Reputation: 1726
Place Response.Redirect to the same page after save logic done. This happens because browser repeat last request on F5 in you case this is POST request to save. After Response.Redirect last request will be GET and you problem will be solved
Upvotes: 3