Home
|
Software
|
WebLog
|
Contact
|
Wish List
navigation
software
RxFind - Search/Replace
.net DatabaseUtility lib.
GAlert - Gmail Notify
code, scripts, etc...
Akismet .Net 2.0 API
Price vs Cost
WebLogs / Blog
Page Comments
Cookie Detection
Refresh Detection
Global Error Handler
Easy HTTP .Net
California Lottery
ASP.NET HTML Template
Bookmarklets
tech articles
Extend ASP 2.0 security
Safe Web Surfing
toys and gadgets
T-Mobile Sidekick II
Sony DirecTiVo
GT I-Drive 6.0 (bike)
Bit Char-G (R/C car)
SolarSpeeder
Canon PowerShot s200
active projects
WebLogs
PageComments
WasArrested.com
mygurus.net
Refresh Detection (Asp.NET)
Download binary project - 9 Kb
Download source project - 11 Kb
Overview
Many websites suffer from the form browser refresh problem. For example, let's say you have a shopping cart. After the user buys item X, the page displays an invoice. The user refreshes the page, which asks if he'd like to repost the form. The user clicks "Retry" and the form is submitted again, charging his credit card and adding a duplicate order.
To fix this problem I have created a control (inspired by Dino Esposito's browser refresh detection code) that can be simply slipped into every page that may suffer from the form repost problem.
If you found this or any other code on this site usefull and want to show your appreciation, now you can. Thanks!
Example
Below is an example; a button that posts a form. (Most forms have text box fields, but for this example they are not necessary and have been omitted).
Page Status:
This page has
NOT
been refreshed.
Button Status:
This button has been clicked
0 times
.
Click the button and press your browsers refresh button to test the refresh detection.
My
contact form
now detects browser refresh to eliminate multiple submissions. Please feel free to test it out and send me an email :)
Visual Studio Toolbox Installation
Add the control to your toolbox. Go to Tools > Customize Toolbox. Click the tab .Net Framework Components. Click on Browse, locate Joel.Net.Refresh.dll and click ok. You should now see "Refresh" in the toolbox.
post reply to this comment
Comment by
Darin
[Jul 15, 2004 @ 9:50 PM]
Know where I could get my hands on that refresh dection source code? Thanks, Darin
post reply to this comment
Comment by
Joel Thoms
[Jul 17, 2004 @ 1:28 AM]
I got it out of an old magazine. I don't think I have it anymore. you might be able to get the code sample here... http://www.dotmugs.ch/events/event.aspx?eid=17
post reply to this comment
Comment by
yarko
[Dec 10, 2004 @ 7:52 PM]
Yes, that code looks to be posted on that site, but you have to register w/ the Swiss user's group - and registration is only available for local people...
read replies to this comment
read replies to this comment
post reply to this comment
Comment by
robertfrost2234
[Feb 01, 2010 @ 6:04 PM]
Apple Mac computer is becoming more and more popular nowdays. Especially designed for Mac users, <a href="http://www.macdvdcopy.com/"> Mac DVD Copy</a> allows you to copy DVD movie in 1:1 ratio like copy D5 to D5 and copy D9 to D9. It can copy your DVD on Mac with the original quality 100% preserved and at the same time remove DVD protections such as CSS, RC and RCE. If you consider in making a personal DVD backup on Mac or burning a new DVD for collection, you are sure not to Miss Mac DVD Copy. With this powerful <a href="http://www.macdvdcopy.com/"> Mac DVD Copy</a> software, you can easily <a href="http://www.macdvdcopy.com/copy-dvd-on-mac.html"> Copy DVD on Mac</a>. This <a href="http://www.macdvdcopy.com/dvd-protected-copy-for-mac.html"> DVD Copy for Mac</a> software is now only $29.00 for you as a new year's gifts.
read replies to this comment
read replies to this comment
post reply to this comment
Comment by
Alexander Popov
[Apr 05, 2005 @ 4:26 AM]
It's not full protection. 1. open page 2. duplicate it ( ctrl-n ) 3. press Button on first ( OK ) 4. press Button on second. "This page HAS been refreshed." message appears ( Bug ) Did you know any techique to prevent this behavior?
post reply to this comment
Comment by
Joel Thoms
[Apr 12, 2005 @ 7:17 PM]
The code does not take into account simultaneous multiple requests from the same user. It may be possible to detect this by assigning a unique identifier when the page is first loaded. I'm currently working on other projects, but the source code is available and if anyone wishes to add this into the control, please send me the code and I will update the builds.
read replies to this comment
read replies to this comment
post reply to this comment
Comment by
jon
[Dec 26, 2005 @ 10:17 PM]
hi Nice code :)
read replies to this comment
post reply to this comment
Comment by
khirod kumar
[Mar 17, 2006 @ 3:51 AM]
hi,
Very good source.
read replies to this comment
post reply to this comment
Comment by
Mahmoud Tahoon
[May 14, 2006 @ 2:53 AM]
your code is just great, it did help me .. thank you very much.
read replies to this comment
post reply to this comment
Comment by
Shah bhavik
[Dec 19, 2006 @ 10:27 PM]
I understand your src code. but In the src code Refresh1 is defined and it is used in the binary file.
so please give me the proper source code.
Your code is great.
Thanks
read replies to this comment
post reply to this comment
Comment by
rishi
[Jan 15, 2007 @ 2:05 AM]
My contact form now detects browser refresh to eliminate multiple submissions.
here hyper link on "contact form" is not working
read replies to this comment
post reply to this comment
Comment by
Tester
[Feb 04, 2007 @ 11:22 PM]
There is a but with this code. When you first come to this page, click on the "Clicke Me" button to so the button status is "..clicked 1 times".
Now leave this page by using the navigation to the left (click on the cookie detection link). Once one the cookie detection page, use the navigation again and click on the Refresh Dection link. Notice that when you return back to Refresh Dection page, it thinks the page was refreshed.
If this is not a bug, please let me know why this occurs.
post reply to this comment
Comment by
robertfrost2234
[Feb 01, 2010 @ 6:14 PM]
Apple Mac computer is becoming more and more popular nowdays. Especially designed for Mac users, [url=http://www.macdvdcopy.com/] Mac DVD Copy[/url] allows you to copy DVD movie in 1:1 ratio like copy D5 to D5 and copy D9 to D9. It can copy your DVD on Mac with the original quality 100% preserved and at the same time remove DVD protections such as CSS, RC and RCE. If you consider in making a personal DVD backup on Mac or burning a new DVD for collection, you are sure not to Miss Mac DVD Copy. With this powerful [url=http://www.macdvdcopy.com/] Mac DVD Copy[/url] software, you can easily [url=http://www.macdvdcopy.com/copy-dvd-on-mac.html] Copy DVD on Mac[/url]. This [url=http://www.macdvdcopy.com/dvd-protected-copy-for-mac.html] DVD Copy for Mac[/url] software is now only $29.00 for you as a new year's gifts.
read replies to this comment
read replies to this comment
post reply to this comment
Comment by
Amit
[Mar 01, 2007 @ 8:13 PM]
I have 8 pages in my application. Starting from 2nd page I have your control on each page to detect page refresh. However when the user navigates from 1st page to 2nd page, the property IsRefreshed of control is set to TRUE from the start. Is this a bug?
Thank you.
read replies to this comment
post reply to this comment
Comment by
Leendert Halter
[Jun 11, 2007 @ 1:36 AM]
Trying to install the Refresh control I encounter the following problem in VS2005 (working with VM ware):
1. SelectTools/Choose Toolbox Items menu
2. Select tab .NET Framework Components
3. browse and select Joel.Net.Refresh.dll yields error message:
"Invalid URI: The hostname could not be parsed". Why is this and what can I do to solve this?
The host name is: amsdc1-s-6133.europe.shell.com
read replies to this comment
post reply to this comment
Comment by
Aries
[Aug 13, 2007 @ 7:33 PM]
Hey, I found a bug here. Copy this URL: http://joel.net/code/refresh_capture.aspx and then click on any other link and browse away from this page. Once you are in a different page, paste the above URL and it will say: The page HAS been refreshed. I have a similar problem, can't seem to get away with it.
read replies to this comment
post reply to this comment
Comment by
Joseph Humphrey
[Sep 09, 2007 @ 8:33 PM]
Based on this example I have rewritten the code to work with ajax and can be used as a base page in the App_Code folder.
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// Summary description for DomPage
/// </summary>
public class DomPage : Page
{
bool _isrefresh = false;
string _tname = "__Ticket";
/// <summary>Increments ticket and checks the last ticket served. All the work is here.</summary>
public DomPage()
{
this.PreInit += new EventHandler(DomPage_PreInit);
}
void DomPage_PreInit(object sender, EventArgs e)
{
// Change null to 0 (prevents errors)
if (Session[_tname + "_LastServed"] == null || Request[_tname] == null) { Session[_tname + "_LastServed"] = 0; }
// Get current and last ticket served
int ticket = Convert.ToInt32(Request[_tname]) + 1;
int lastticket = Convert.ToInt32(Session[_tname + "_LastServed"]);
// Refresh detection
if (ticket > lastticket || (ticket == 0 && lastticket == 0))
Session[_tname + "_LastServed"] = ticket;
else
_isrefresh = true;
}
/// <summary>Outputs hidden field with ticket id.</summary>
/// <param name="output">Html Text Writer</param>
protected override void Render(HtmlTextWriter output)
{
//Checks if the page is using Ajax
if (ScriptManager.GetCurrent(this) != null)
ScriptManager.RegisterHiddenField(this, _tname, Session[_tname + "_LastServed"].ToString());
else
Page.ClientScript.RegisterHiddenField(_tname, Session[_tname + "_LastServed"].ToString());
base.Render(output);
}
/// <summary>Returns true if page has been refreshed, otherwise false.</summary>
public bool IsRefresh
{
get { return _isrefresh; }
}
}
read replies to this comment
post reply to this comment
Comment by
Joseph Humphrey
[Sep 09, 2007 @ 8:35 PM]
You may want to remove the html breaks.. The comment added those :)
read replies to this comment
post reply to this comment
Comment by
Daniel
[Sep 06, 2008 @ 5:04 AM]
Hi Joel,
How do I detect a new tab in Internet Explorer?
I have an ASP.NET page which hosts my application. I can detect a new session for a user through session_start in global.asax. I can detect a refresh though the server page_load event. But to detect a new tab, I have few possible options to try out:
1) identify HTTP_Connection ?
2) count the static objects in Session ?
3) Response.IsClientConnected ?
4) HTTP_REFERER ?
I don't know if any of these will do it. Please help!!
Thanks
read replies to this comment
post reply to this comment
Comment by
massage shanghai
[Dec 21, 2008 @ 5:08 PM]
massage shanghai,???[url=http://www.shanghaimassage9.com]massage shanghai[/url]???????,???massage shanghai??????,??????massage shanghai????,,????massage shanghai,?????,??????massage shanghai????J??????Massage table????????[url=http://www.massageoem.com/en/Products_list.asp?classid=1]Massage table[/url]???,Massage table??·,????Massage table???????????,?????Massage table?????Z?????????[url=http://www.massageoem.com]Massage table[/url]??????????????Massage table???,????U????Massage table??????????????????????Massage table????????????[url=http://www.wholesalenikesneaker.com/product.asp?Classid=50&Nclassid=513&i=1]max 90[/url]???????????max 90??????????max 90?????max 90??????max 90??????max 90??
????[url=http://www.topsofts.com/office_tools/221.html]microsoft office[/url](?????????)????????????j?microsoft office????????????????microsoft office??????microsoft office??????microsoft office??????microsoft officeMifare card????,[url=http://www.e-plasticcard.com/Mifare_card.htm]Mifare card[/url]???????,Mifare card??????,????Mifare card????,????Mifare card??????,????Mifare card???????mobile software???,[url=http://www.topsofts.com/internet/mobile/73/82.html]mobile software[/url]???,mobile software???,mobile software????,??mobile software,??mobile software,mobile software????,??mobile software,???mobile software,mobile software???
???moblie download???? ????[url=http://www.topsofts.com/internet/mobile/73/82.html]moblie download[/url]??? ???moblie download???? ???????moblie download ??????moblie download
read replies to this comment
post reply to this comment
Comment by
dvd ripper
[Mar 16, 2009 @ 11:30 PM]
????dvd ripper???[url=http://www.topsoftwareol.com/product/DVD/DVD_Ripper.html]dvd ripper[/url]ý?????ý????dvd ripper????dvd ripper????dvd ripper??????dvd ripperý????ý????[url=http://www.topsoftwareol.com/products/dvd-ripper.html]dvd ripper[/url]??????dvd ripper?????????dvd ripper??????????????dvd ripper?????????????dvd ripperdvd ripper for mac????. [url=http://www.topsoftwareol.com/product/MAC/DVD_Ripper.html]dvd ripper for mac[/url]???????????dvd ripper for mac; dvd ripper for mac????????. ???dvd ripper for mac??? ???[url=http://www.topsoftwareol.com/product/MAC/DVD_Ripper.html]dvd ripper mac [/url]????????????dvd ripper mac ??????,??????dvd ripper mac ý??dvd ripper mac ????dvd ripper mac ?????dvd ripper mac ???º?dvd ripper mac ?????????[url=http://www.topsofts.com/dvd_video/16.html]dvd software[/url]???????dvd software???ID??IP, dvd software?????????I????? .... dvd softwareg??. - dvd software?????????dvd software??g????[url=http://www.topsofts.com/dvd_video/16.html]dvd software [/url]ó?????????????dvd software ?????????????????????dvd software ???????????dvd software ??????ecosway?????|???[url=http://www.ekosv.cn]ecosway[/url]????????????ecosway??ecosway????????Adjobs.com.cn??????ecosway?????????[url=http://www.andarm.net]Electro Shocker[/url](?????????)????????????j?Electro Shocker????????????????Electro Shocker??????Electro Shocker??????Electro Shocker??????Electro Shocker
read replies to this comment
post reply to this comment
Comment by
Ess Dee
[May 31, 2009 @ 6:46 PM]
this is good.
read replies to this comment
post reply to this comment
Comment by
avi converter for mac
[Jul 27, 2009 @ 9:31 PM]
???????[url=http://www.dvdsoftwares.de/product/DVD_to_AVI_Converter_for_Mac.html]avi converter for mac [/url]????. ???avi converter for mac ????. ???avi converter for mac ????. ???avi converter for mac ??????? ???????avi converter mac2007????????[url=http://www.topdvdsofts.com/Products/MAC/DVD_to_AVI_Converter.html]avi converter mac[/url]?????????? ... ?????avi converter mac??? .... ?havi converter mac?????????avi converter mac?????????avi converter mac?????????[url=http://www.567software.com/Products/mac/DVD_to_AVI_Converter_for_mac.html]avi converter mac[/url]?????????avi converter mac???,??????avi converter mac???,avi converter mac????????????avi converter mac??????[url=http://www.dvdsoftwares.de/product/DVD_to_AVI_Converter_for_Mac.html]avi converter mac[/url]???????????avi converter mac????? ????????????????avi converter mac?????????????avi converter mac?????????avi converter mac???????????[url=http://www.dvdsoftwares.net/Products/MAC/DVD_to_AVI_Converter.html]avi converter mac[/url]????????????avi converter mac?????avi converter mac??·??????avi converter mac???????avi converter mac???????¡?avi converter mac?????[url=http://www.dvdsoftwares.de/product/DVD_To_AVI_Converter.html]avi dvd converter[/url],avi dvd converter???,????avi dvd converter??,avi dvd converter??????,avi dvd converter?????,??????AVI iPhone Mac??????[url=http://www.dl32.com/product/iPhone/TOP_AVI_to_iPhone_Converter.html]AVI iPhone Mac[/url]?????????AVI iPhone Mac????????AVI iPhone Mac????????????AVI iPhone Mac???????????????AVI iPhone Mac???????????????AVI iPhone Mac????????[url=http://www.dvdsoftwares.de/product/DVD_To_AVI_Converter.html]avi to dvd converter[/url]???u?????????????avi to dvd converter?????????
read replies to this comment
post reply to this comment
Comment by
bearking
[Nov 03, 2009 @ 12:47 AM]
[url=http://www.xilisoft.com/blu-ray-to-dvd-suite.html]blu-ray to dvd[/url]
read replies to this comment
post reply to this comment
Comment by
bearking
[Nov 03, 2009 @ 12:52 AM]
Xilisoft iPod Rip permits you to rip, copy or backup your iPod music, videos, photos, podcasts and audio book to PC or the other way around. You can even sync songs between your iTunes 9.0 and you iPod Rip software.
read replies to this comment
post reply to this comment
Comment by
beaking
[Nov 03, 2009 @ 12:55 AM]
Xilisoft iPhone Transfer is a smart tool for synchronizing your iPhone to your computer.
read replies to this comment
post reply to this comment
Comment by
fds
[Nov 10, 2009 @ 5:28 PM]
<a href=http://www.springcare.cn>baby education</a>
read replies to this comment
post reply to this comment
Comment by
nhim
[Nov 17, 2009 @ 12:58 AM]
In 1427, after 10 years of war, <a href="http://miaikan.co.jp/">?? ??</a> Vietnam regained its independence and China <a href="http://miaikan.co.jp/">????? ??</a> officially acknowledged Vietnam as an independent state. Lê L?i took the throne and was declared Emperor of Dai Viet <a href="http://miaikan.co.jp/">?????????</a> (??) (though King is a more accurate term for the ruler of Vietnam)
read replies to this comment
post reply to this comment
Comment by
dvd ripper
[Dec 09, 2009 @ 11:43 PM]
leawo dvd ripper is the best dvd ripper
read replies to this comment
Leave Your Comment
Name:
Email:
(gravatar enabled)
URL:
Comment:
or
Cancel
Leave a Comment