如何计算下载次数.
问题描述:
大家好,
假设我有一个文件显示在网页上作为链接.当我下载该文件时,它将显示为
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
答
使用以下代码:希望它可以帮助您解决问题..
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
}
}
Google?
ASP.Net计数下载点击次数 [在ASP.NET中下载文件并跟踪下载成功/失败状态 [ ^ ]
Google?
ASP.Net Count Download Clicks[^]
Also check CP article File Download in ASP.NET and Tracking the Status of Success/Failure of Download[^]
可靠地执行此操作的唯一方法是将计数保存在数据库中,并在页面加载时检索值.
The only way to do this reliably is to save the count in a database, and retrieve the value whenever the page is loaded.