Reputation: 349
As title state after my solution on aspx.cs I want to switch to another web page to remove cookies and avoid resending the same email.
Upvotes: 0
Views: 346
Reputation: 218832
Do the PRG pattern
After you done with your transaction, Redirect to another page (showing "It is done successfully" or some other message). Now Refresh can not beat you
To Redirect, You can use Response.Redirect
method
Response.Redirect("welcome.aspx")
Upvotes: 4
Reputation: 103388
You could add a Session
which prevents the email being sent again (if this is a once per session email (ie. Newsletter sign up etc)).
Then check whether this Session
exists before sending the email:
if (Session["emailsent"]==null){
//Send email code here
Session["emailsent"] = true;
}
Upvotes: 2
Reputation: 3919
you have to test in your page_load event
if(!IsPostBack)
{
//send mail...
}
else
{
//do nothing
}
Upvotes: 0