开发者

How to Prevent Submitting Data during Refresh

as i am developing a web application in asp.net, There is 4 text boxes to provide user deatils and a button to save the information in DB. When User click the button to Insert the user deatil, it is saved in DB perfectly, but the problem is when the user Refreshes the page, that data is again re inserted / resubmitted, i want to make sure that duplicate submission should be av开发者_如何转开发oided .

Please any suggestion, code samples, to avoid this situation are welcome ( in c#)


Use the Post-Redirect-Get (also known as Redirect after post) pattern. It simply consists in redirecting after a successful post, so that the user refresh results in an idempotent GET to be done rather than a POST. It has the additional advantage that the browser "forgets" about the POST in its history, which means the back button won't submit either.


Put a field in page call it status for example, after submitting first time it's populated with SUCCESS. If it is the do not save again.

Not the ultimate solution for sure.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜