PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

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

 
 
Brian Simmons
Guest
Posts: n/a
 
      25th May 2007
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


 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      25th May 2007
"Brian Simmons" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> 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

 
Reply With Quote
 
vcuankitdotnet
Guest
Posts: n/a
 
      25th May 2007
You might also try:

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

 
Reply With Quote
 
Brian Simmons
Guest
Posts: n/a
 
      25th May 2007
Thanks Mark, I tried google, but didn't use that keyword: prevent
Muchas gracias!

"Mark Rae" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Brian Simmons" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> 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



 
Reply With Quote
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      25th May 2007
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......
> }
>
>

 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      28th May 2007
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.


 
Reply With Quote
 
Brian Simmons
Guest
Posts: n/a
 
      29th May 2007
Hi Steven,

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

Thanks,
Brian

"Steven Cheng[MSFT]" <(E-Mail Removed)> wrote in message
news:%23JE%(E-Mail Removed)...
> 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.
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Code to Refresh inbound data sheets, then Refresh Pivot Tables AFSSkier Microsoft Excel Programming 3 4th Sep 2009 07:59 PM
avoiding double post when user refresh browser Jeff Microsoft ASP .NET 4 27th Mar 2009 01:42 PM
Refresh Query Table causing debug error with Background Refresh pr Gum Microsoft Excel Programming 2 12th Mar 2009 10:08 PM
with back command how can I get all pages to automatically refresh (without hitting refresh button) =?Utf-8?B?dmluY2VuMTE=?= Windows XP General 1 25th Apr 2004 03:22 PM
Pivot Table REFRESH Flaw -- Saves Old Data in Selection Area AFTER REFRESH Ken Roberts Microsoft Excel Programming 3 11th Sep 2003 06:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:09 PM.