Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Code is reexecuted when the user clicks Refresh

Reply
Thread Tools

Code is reexecuted when the user clicks Refresh

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      01-19-2007
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
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
RSH
Guest
Posts: n/a
 
      01-19-2007
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>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
> (E-Mail Removed)
> http://www.nathansokalski.com/
>



 
Reply With Quote
 
 
 
 
Keith Patrick
Guest
Posts: n/a
 
      01-19-2007
Maybe Response.Redirect? That will flush out your POST headers to prevent
the submit from happening repeatedly



 
Reply With Quote
 
\(O\)enone
Guest
Posts: n/a
 
      01-19-2007
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


 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      01-20-2007
Nathan,

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

Cor

"Nathan Sokalski" <(E-Mail Removed)> schreef in bericht
news:%(E-Mail Removed)...
>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
> (E-Mail Removed)
> http://www.nathansokalski.com/
>



 
Reply With Quote
 
Spam Catcher
Guest
Posts: n/a
 
      01-20-2007
"Nathan Sokalski" <(E-Mail Removed)> wrote in
news:#(E-Mail Removed):

>
> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When user clicks BACK, force refresh and auto scroll. Badass Scotsman Javascript 1 04-27-2006 01:13 AM
Refresh when user clicks back button morc Javascript 4 02-14-2006 01:54 PM
Clicks and double-clicks PontiMax ASP .Net Datagrid Control 2 07-14-2004 11:00 AM
Button clicks everytime I refresh screen???... Trint Smith ASP .Net Web Controls 4 02-24-2004 05:54 PM
How to detect when user clicks on a broken link to an external web page. ASP .Net 1 10-30-2003 07:58 PM



Advertisments