Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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 27-Dec-11 4:45am
3796068860
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
use following code: hope it will help you n solve your problem..
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
     }
}
  Permalink  
v2
Comments
Mika Wendelius at 27-Dec-11 11:22am
   
Pre tags added
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Comments
Mika Wendelius at 27-Dec-11 13:47pm
   
My 5.
Espen Harlinn at 30-Dec-11 9:31am
   
5'ed!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

The only way to do this reliably is to save the count in a database, and retrieve the value whenever the page is loaded.
  Permalink  
Comments
Espen Harlinn at 30-Dec-11 9:32am
   
5'ed!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

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.
  Permalink  
Comments
Espen Harlinn at 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)

  Print Answers RSS
0 OriginalGriff 190
1 Jochen Arndt 165
2 PIEBALDconsult 150
3 BillWoodruff 148
4 DamithSL 140
0 OriginalGriff 5,695
1 DamithSL 4,591
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 27 Dec 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100