Click here to Skip to main content
15,903,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ,

I develop asp.net page.
I have a form to fill and send.
After clcik send button and return to client , if client press F5
the page process seems like client press send button again
how I can prevent from this action

Thanks
Posted

I have good solution for this....

Encode your url to current datetime using and then add this url into session object e.g.

Session("update")=Server.URLEncode(System.DateTime.Now.ToString())

Add this session to view state. For this, you can use page pre_render event

Sub Page_PreRender (sender As Object, e As EventArgs)
    ViewState("update") = Session("update")
End Sub


and finally check this session to view state
If (Session("update").ToString() == ViewState("update").ToString())
{
//your code for inserting... updating... etc.
}
 
Share this answer
 
F5 reloads a page, which means it posts the data from the last action, which was the post with the postback data. To avoid this, when you've processed the data, do a Response.Redirect or a Server.Tranfer back to the page you are on, this replaces the postback with a load of the page with no postback data. I remember clearly doing this in an ecommerce site, but I don't recall which of the two I used, or if both work, so try both and one will definitely do it for you.
 
Share this answer
 
To work with the email forms look php form tutorial. Perhaps you have something wrong with the code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900