Home | Software | WebLog | Contact | Wish List

Refresh Detection (Asp.NET)

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.