I have a web page with a form and a submit button, and in the server side I used a session value to prevent the form submit twice, which is like the initial value of the session is 0 and turn it to 1 after user click submit button, every time submit button will check the session value first.
But, when our project published, I found there were two records for the same person (which means they submit twice I guess, and it didn't happen very often maybe on one or two persons), and the time interval between these two records is very small, like 0.3 second, so first I thought they might double click the submit button, but after I tried on my computer, it still only insert one record into the database
I am confused how does this happen, and how to prevent it?
Here is the code:
protected void Page_Init(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["IsBackForwordPayment"] = 0;
}
}
protected void submit_Click(object sender, EventArgs e)
{
if (Session["IsBackForwordPayment"] != null && Session["IsBackForwordPayment"].ToString() != "0")
Response.Redirect("~/pages/renewal/duplicaterenewal.aspx");
.......
}
Is it possible because that after checking the session value the program just redirect to another page but not terminate the submit process ??