Pergunta

I am working on a Classic ASP application hosted on IIS 6. User can enter the details in Enter_details.asp page and click on send email button to receive email confirmation. After clicking on Send email button, page is redirected to email.asp page and email is sent.

If users refresh the email.asp page, a duplicate email is sent with the same details. How to check if an ASP page is redirected or refreshed and avoid duplicate emails?

Page1: Enter_Details.asp page

<form action="email.asp" method="POST">

<input type="Submit" name="Submitbutton" value="Send E-Mail">

Page 2: Email.asp

code to send email goes here.

What i want is to alert the user if an email is already sent.

How to check if an ASP page is redirected or refreshed?

Foi útil?

Solução

The page the user ends up on shouldn't be the one to actually do the emailing.

In your situation, Enter_details.asp submits data to email.asp, which does the emailing, and tells the user the email has been sent. Hence, if it is reloaded, both actions will be repeated.

If you leave the emailing functionality where it is in email.asp, and when this is complete, do a Response.Redirect to a new page emailConfirmation.asp which simply tells the user whether the email has been sent successfully or not (you could pass a success flag, and any other details required, through to it via Querystring or Session from email.asp).

Then, if emailConfirmation.asp is reloaded, no duplicate emails will be sent.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top