Akyl
Akyl

Reputation: 349

visual studio 2010 c# traverse between web pages on aspx.cs

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

Answers (3)

Shyju
Shyju

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

Curtis
Curtis

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

Hassan Boutougha
Hassan Boutougha

Reputation: 3919

you have to test in your page_load event

if(!IsPostBack)
{
//send mail...
}
else
{
//do nothing
}

Upvotes: 0

Related Questions