468,251 Members | 1,353 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,251 developers. It's quick & easy.

Avoiding a refresh in ASP.NET 2, how-to?

Hi all,

I come from a ColdFusion background, and the majority of the time, here's
how we processed a page:
1) The Data entry page would have a submit button which would post to an
action page
2) The action page would do the validation and database processing, if
successful, the action page would <cflocation(similar to a
Response.Redirect or Server.Transfer) to a display page.

If the end-user hit F5 or Refresh on the toolbar of the browser, the final
display page would be refreshed, not the original page or the action page.
This prevented the database processing from occuring twice.

Note: the original data entry page DOES NOT post back to itself, like in
ASP.NET.

So, now that I'm on the ASP.NET 2 bandwagon, I'm curious as to how to
prevent the double database processing happening if/when a user clicks
F5/Refresh.

I'm noticing that on pages which I have an insert, delete, or updating going
on, the user submits the changes, and then when the page comes back...If the
user clicks Refresh/F5, then the page (will show the postback warning which
most users don't read and/or understand) will attempt to do the database
action again, thus causing potential problems.

Suggestions?

Thanks,
Brian
May 25 '07 #1
6 14659
"Brian Simmons" <ce******@newsgroup.nospamwrote in message
news:uW**************@TK2MSFTNGP06.phx.gbl...
So, now that I'm on the ASP.NET 2 bandwagon, I'm curious as to how to
prevent the double database processing happening if/when a user clicks
F5/Refresh.
Google is your friend:
http://www.google.co.uk/search?sourc...revent+Refresh
--
http://www.markrae.net

May 25 '07 #2
You might also try:

if (!Page.IsPostback)
{
.......code that you only want to process once......
}

May 25 '07 #3
Thanks Mark, I tried google, but didn't use that keyword: prevent
Muchas gracias!

"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:eE*************@TK2MSFTNGP06.phx.gbl...
"Brian Simmons" <ce******@newsgroup.nospamwrote in message
news:uW**************@TK2MSFTNGP06.phx.gbl...
>So, now that I'm on the ASP.NET 2 bandwagon, I'm curious as to how to
prevent the double database processing happening if/when a user clicks
F5/Refresh.

Google is your friend:
http://www.google.co.uk/search?sourc...revent+Refresh
--
http://www.markrae.net

May 25 '07 #4
That won't help in the situation described by the OP, since if the last
action was an HTTP POST and you hit Refresh on your browser, it's going to do
the POST again.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"vcuankitdotnet" wrote:
You might also try:

if (!Page.IsPostback)
{
.......code that you only want to process once......
}

May 25 '07 #5
Hi Brian,

For ASP.NET web page model, if you still want to prevent duplicated submit
of page postback processing, you can still use the same way like what you
do in code fusion. You can let the ASP.NET page postback(when click button
or other postback control) as normal, and do the server-side processing in
page/control's postback event, however, after the processing code , you add
an additional statement to redirect the page. e.g.

Response.Redirect("the page itself....")

Thus, after the page is successuflly finishing the postback, it won't
suffer from duplicated submit issue. How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
May 28 '07 #6
Hi Steven,

Thank you for the reply. I implemented the solution exactly as you
specified. Works like a charm.

Thanks,
Brian

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:%2******************@TK2MSFTNGHUB02.phx.gbl.. .
Hi Brian,

For ASP.NET web page model, if you still want to prevent duplicated submit
of page postback processing, you can still use the same way like what you
do in code fusion. You can let the ASP.NET page postback(when click button
or other postback control) as normal, and do the server-side processing in
page/control's postback event, however, after the processing code , you
add
an additional statement to redirect the page. e.g.

Response.Redirect("the page itself....")

Thus, after the page is successuflly finishing the postback, it won't
suffer from duplicated submit issue. How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.


May 29 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Tom Post | last post: by
10 posts views Thread by Nick Craig-Wood | last post: by
7 posts views Thread by Leonardo D'Ippolito | last post: by
6 posts views Thread by vvenk | last post: by
2 posts views Thread by Dan | last post: by
2 posts views Thread by Ted Dawson | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.