Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,


Suppose i have a file which is display in the webpage as a link.When i download that file it will show the count as
Download:1
times.It will go on increasing with every download.


How to achieve it.Please help?




Thanks
Posted

Hi,
use following code: hope it will help you n solve your problem..
C#
protected void Page_Load(object sender, EventArgs e)
{
     int id;
     if (Int32.TryParse(Request.QueryString["file"], out id))
     {
          Count(id); // increment the counter
          GetFile(id); // go to db or xml file to determine which file return to user
     }
}
 
Share this answer
 
v2
Comments
Wendelius 27-Dec-11 11:22am    
Pre tags added
 
Share this answer
 
Comments
Wendelius 27-Dec-11 13:47pm    
My 5.
Espen Harlinn 30-Dec-11 9:31am    
5'ed!
The only way to do this reliably is to save the count in a database, and retrieve the value whenever the page is loaded.
 
Share this answer
 
Comments
Espen Harlinn 30-Dec-11 9:32am    
5'ed!
When you click on Download link then save download count plus 1 in database and on page load fetch Count from Database and show on page.
 
Share this answer
 
Comments
Espen Harlinn 30-Dec-11 9:32am    
5'ed!

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