Click here to Skip to main content
15,893,337 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
After uploading a document, if we click on browser refresh button,it will send the request again and the same document gets uploaded again,Can any one Suggest the best way to tackle this.
Posted

1. Redirect the page to a new one. Make you set Cache off for the upload page. Hence, the user hits back button, He gets page unavailable.

2. Use a Flag of some sort at Page level/user Level/Application level to identify a completed upload.
 
Share this answer
 
Comments
chkrvrthy 14-Feb-12 14:24pm    
Hi jyothi,
Thanqu for quick response.My requirement is not to navigate any page after uploading the document, it must be stay on the same page and shows the list of added document.If i clicking refreshing list is updating,Can you provide pagelevel
or any other solution.
That's why your have your server part to tell the difference of the state before and after uploading.

Let's assume you have form on the page using the method "POST", and the target URI will be the same as referral page which is prescribed by the action attribute of the form tag. You feel in some data, part of this data is the file. When you click "Submit" button you start uploading, receive HTTP response which you the page with the same URI. When a server side generates this page, it has some information to be taken into account: 1) post data is not empty; 2) the uploaded file physically present in the file system of the server. As HTTP protocol is stateless, your should rely on some change in state as it is stored on the server side; the presence of the file is one of the changes; and this is a very simple example.

In more complex situation, you may want to track the history of submissions of files by some user and more. This data can be stored in database and serves as a persistent state data available between HTTP request. Every time you process HTTP request and generate HTTP response, you can use this data to modify response accordingly, no matter if your request URI is the same or different — it does not carry state information.

In general case, you use session state management, please see:
http://msdn.microsoft.com/en-us/library/ms178581.aspx[^].

See also this article: http://msdn.microsoft.com/en-us/magazine/cc163730.aspx[^].

Please see also these CodeProject articles:
Session Management in ASP.NET[^],
Session management options in ASP.NET[^],
ASP.NET Session Management Internals[^].

—SA
 
Share this answer
 
One simple solution is keep the status in hidden filed that file has uploaded,
so based on the status 2nd time you should not upload the file once again ...
 
Share this answer
 
try this with simple solution,

after uploading the file you have to redirect page into same page using Response.Redirect('pageurl').
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900