471,595 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,595 software developers and data experts.

Code is reexecuted when the user clicks Refresh

I have a page which allows the user to send emails. After they click the
submit button, I display a confirmation message. However, if the user clicks
the browser's Refresh button once the confirmation message is displayed, the
email is sent a second time (or a third, fourth, fifth, etc.). What can I do
to prevent the Refresh button from resending the email? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Jan 19 '07 #1
5 1059
RSH
Nathan,

You could set a session varaible that once the email was sent the session
variable would be sent and you would add a wrapper to check for a value in
the session variable before sending emails.

If they hit the refresh button does that cause a postback...I'm not sure.
If not, then you can simply check if the request is a postback...if it is
send the email...else dont.

HTH
Ron
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>I have a page which allows the user to send emails. After they click the
submit button, I display a confirmation message. However, if the user
clicks the browser's Refresh button once the confirmation message is
displayed, the email is sent a second time (or a third, fourth, fifth,
etc.). What can I do to prevent the Refresh button from resending the
email? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Jan 19 '07 #2
Maybe Response.Redirect? That will flush out your POST headers to prevent
the submit from happening repeatedly

Jan 19 '07 #3
Keith Patrick wrote:
Maybe Response.Redirect? That will flush out your POST headers to
prevent the submit from happening repeatedly
This is the approach we use. It works perfectly.

--

(O)enone
Jan 19 '07 #4
Nathan,

You can try to set a session variable that tells that the post has been
send.

Cor

"Nathan Sokalski" <nj********@hotmail.comschreef in bericht
news:%2****************@TK2MSFTNGP05.phx.gbl...
>I have a page which allows the user to send emails. After they click the
submit button, I display a confirmation message. However, if the user
clicks the browser's Refresh button once the confirmation message is
displayed, the email is sent a second time (or a third, fourth, fifth,
etc.). What can I do to prevent the Refresh button from resending the
email? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Jan 20 '07 #5
"Nathan Sokalski" <nj********@hotmail.comwrote in
news:#K**************@TK2MSFTNGP05.phx.gbl:
>
I have a page which allows the user to send emails. After they click
the submit button, I display a confirmation message. However, if the
user clicks the browser's Refresh button once the confirmation message
is displayed, the email is sent a second time (or a third, fourth,
fifth, etc.). What can I do to prevent the Refresh button from
resending the email? Thanks.
Session variables, database flag, cookies - since the web is stateless,
you'll need some sort of mechanism to track when the last request occured
and if the current request is valid.
Jan 20 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Jo | last post: by
10 posts views Thread by Tom Bower | last post: by
4 posts views Thread by morc | last post: by
1 post views Thread by Badass Scotsman | last post: by
5 posts views Thread by Nathan Sokalski | last post: by
3 posts views Thread by Mike | last post: by
4 posts views Thread by Peter | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.