Nishant Nishant - 1 year ago 71
ASP.NET (C#) Question

Prevent browser from re-sending form information that has allready submitted to server

How can I prevent user to resend data by refreshing the URL ?

(Actually after posting data to the server and returning back data by the server to the client: if user refreshes the url address then again he sends back to the server with previous data)

So, how can I prevent it by c#, ?

Answer Source

supposedly, if it is POST, the browser should ask the user whether to send the data again, so just refreshing the same URL alone won't cause that to happen.

If you want to prevent the user from saying "Yes" and have the same data posted to the server again, you can use a timestamp and/or a random number to prevent the same data posted to the server. If the same timestamp and/or random number is already in the DB for that user, then handle it as a duplicate -- or ask the user whether to do the same action again.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download