473,804 Members | 2,119 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to detect users refresh in my asp.net page

J-T
Is there a way to detect if a user has refreshed a page in asp.net?

Thanks a lot
Nov 19 '05 #1
5 1479
You'll get another request to the page. What are you trying to do?

-Brock
DevelopMentor
http://staff.develop.com/ballen
Is there a way to detect if a user has refreshed a page in asp.net?

Thanks a lot

Nov 19 '05 #2
Are you trying to detect a double GET or a double POST?

Nov 19 '05 #3
You may keep a counter session variable and increase that per each request.
A copy of this value is also stored on the client side (for example on the
query string). If the request is being sent multiple times by hitting the
browser refresh button, you can detect it on the server side by comparing
the counter.

Regards,
Jack Li
MVP (ASP.NET)

"J-T" <J-*@nospam.com> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
Is there a way to detect if a user has refreshed a page in asp.net?

Thanks a lot

Nov 19 '05 #4
J-T
I have a form :

<form id="frmUpload" name="UploadFil eFromClientForm " method="post"
encType="multip art/form-data" runat="server">
......

<INPUT id="UploadTheFi le" type="button" value="Upload" name="UploadThe File"
runat="server">
.......
</form>

and here is the code behind it:
private void UploadTheFile_S erverClick(obje ct sender, System.EventArg s e)

{

HttpPostedFile file = File1.PostedFil e;

byte[] fileData = new byte[file.ContentLen gth];

file.InputStrea m.Read(fileData , 0, file.ContentLen gth);

uploader.FileNa me=Path.GetFile Name(file.FileN ame);

uploader.Upload ();
}

whenever the user refreshes the page UploadTheFile_S erverClick is being
called and another record with the same information is being inserted into
my database.

Any,suggestions ?

Thanks
Nov 19 '05 #5
J-T wrote:
I have a form :

<form id="frmUpload" name="UploadFil eFromClientForm " method="post"
encType="multip art/form-data" runat="server"> .....

<INPUT id="UploadTheFi le" type="button" value="Upload"
name="UploadThe File" runat="server"> ......
</form>

and here is the code behind it:
private void UploadTheFile_S erverClick(obje ct sender,
System.EventArg s e)

{

HttpPostedFile file = File1.PostedFil e;

byte[] fileData = new byte[file.ContentLen gth];

file.InputStrea m.Read(fileData , 0, file.ContentLen gth);

uploader.FileNa me=Path.GetFile Name(file.FileN ame);

uploader.Upload ();
}

whenever the user refreshes the page UploadTheFile_S erverClick is
being called and another record with the same information is being
inserted into my database.

Any,suggestions ?


A synchronizer token will help. Here's an article with a sample
implementation: http://tinyurl.com/3ma4x

Cheers,
--
http://www.joergjooss.de
mailto:ne****** **@joergjooss.d e
Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2618
by: Matt | last post by:
When the page is refresh, it will first call window_unload() and then call window_load(). The problem is I window_unload() is invoked when the user click close button, or right top icon close button. I don't want refresh will call window_unload. Any ideas? thanks!! function window_load() {//etc.. }
4
29360
by: sm mehta | last post by:
Hi, I have a web Application that must be licensed. When Customer buys 2 licensees for my application they can only have 2 copies open at a time. What I am doing right now is, I am storing No. Of License in the SQL Table, and on each connection i would reduce 1 license from the DB. My problem is when user closes IE Browser, I want to capture this event and return the license to the DB. How do I know when user closed the browser? I have...
2
3810
by: Leszek Taratuta | last post by:
Hello, I am using the following code to prevent users to see the previous pages: Response.CacheControl = "no-cache"; Response.AddHeader( "Pragma", "no-cache" ); Response.Expires = -1; When users select the "Back" button in IE, they see the message:
3
3290
by: Frank | last post by:
I have an application that is used by multiple people. They all see the same table contents from a sql-db. If a user adds/changes or removes a record the other users must refresh there dataset manually to see the changes. How can I make my application aware of db-changes automaticly so that the users don't have to manually refresh the screen. Thanks, Frank
2
5037
by: Jan | last post by:
Is it possible to somehow redirect users to a cutom page if their browsers/firewall do not support SSL? Almost like a customized 404 page? We'd like to offer SSL form submits by default, but show a special page if SSL is not possible for the user.
1
4854
by: Jessica | last post by:
Hi, I'm sorry if this has been asked before. I'm a designer and occasional javascript hacker, not a javascript writer. I cannot believe I have spent over 4 hours searching for this on Google and nothing I have found solves this silly little problem. Background ---------- I have been assigned a poorly-designed site to SEO. It has a number of
4
7923
by: nrocha | last post by:
Hello, I've been trying to detect when a user closes a page or navigates away from it. This is part of a solution for locking pages (that is, if a user enters a page, no one else can enter it while he doesn't leave). I'm using the window.onunload event to trigger the unlocking of a page, but I don't want the page to be unlocked when a postback or a refresh occurs...I only want it when the user goes to another page or closes the...
1
3235
by: jim bradshaw | last post by:
I have an asp.net page that calls itself recursively if the user selects certain actions on form buttons. The page will be changed in various ways according to the action called for by the user. This works fine, except for the fact that the "action" variable is a hidden field and if the user hits the refresh button or navigates to the page by the "back" button or other methods, the latest "action" will be performed again. Does anyone out there...
0
10600
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10352
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10097
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9175
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5535
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3835
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.