How to build a download tracker?

S

Showjumper

Anyone have any links describing building a download tracker - one that
would log the number of downloads in a database and describe how to send the
file to the user once they have clicker the link. Thanks..
 
M

Marshal Antony

Hi,
Make an aspx file where you have a download link(it can be an anchor
tag or a server control.
If you use a server control such as LinkButton use this code when it is
clicked :
create a table for the downloads for eg : with date and no_of_downloads
and call it download_tracker.
System.IO.FileInfo file = new System.IO.FileInfo(filepath);

if(file.Exists)

{

Response.Clear();

Response.AddHeader("Content-Length", file.Length.ToString());

Response.ContentType = "application/octet-stream";

Response.AppendHeader("Content-Disposition","attachment;filename=" +
file.Name);

update the no_of_downloads in download tracker table for the
corresponding day.

Response.WriteFile(file.FullName);

Response.Flush();

Response.End();

}

if you use another aspx page to do the same put it in Page_Load event of
that page..

when you click an anchor tag(client side)

It is little tricky : you need to send some client side script from that
aspx page to close that page.

Hope this helps ;

Regards,

Marshal Antony

http://www.dotnetmarshal.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top