Resend of data on refresh browser
how to prevent the resend of data to the db when user click on the refresh button of browser....
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Lalit MPosted Jan 16, 2010, 1:47 AM
show this link
http://aspalliance.com/687_Preventing_Duplicate_Record_Insertion_on_Page_Refresh.all
http://forums.asp.net/p/1190997/2045619.aspx
Kirtan PatelPosted Oct 27, 2009, 8:26 AM
after inserting data or Doin Any Procedure
just Redirect Page to Same page
ie ..
Response.Redirect("~/Default.aspx");
that Will not Show resend Data Now
please check "Do you like this answer" if it helps you :)
naura paxPosted Oct 27, 2009, 8:22 AM
I know of a method where you can maintain a session variable to prevent db update on refresh.
Sub Page_Load (sender As Object, e As EventArgs) If Not Page.IsPostBack Session("update") = Server.URLEncode(System.DateTime.Now.ToString()) End If End SubSub Page_PreRender (sender As Object, e As EventArgs) ViewState("update") = Session("update") End Sub Sub Button1_Click(sender As Object, e As EventArgs) If Session("update").ToString() = ViewState("update").ToString() Then If AddEmployee(firstName.Text, lastName.Text) = 0 Message.Text = "Success" Session("update") = Server.URLEncode(System.DateTime.Now.ToString()) Else Message.Text = "Failure" End If Else Message.Text = "Failure - Session" End If firstName.Text = "" lastName.Text = "" End SubShould the user refresh the page, the ViewState variable will be repopulatedfrom the post header, so then the ViewState and Session variables will nolonger hold the same values, and the INSERT command will not run.Read this article for better understanding. http://aspalliance.com/687