日期:2014-05-17  浏览次数:20491 次

asp.net怎么统计软件的下载次数
前台页面:
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="ad112/img.jpg" OnClick="ImageButton1_Click" />
后台:
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        Response.ContentType = "/apk";
        Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("test.apk", System.Text.Encoding.UTF8));
        Response.TransmitFile(Server.MapPath("test.apk"));
        Response.End();
    }
代码如上:点击按钮弹出下载框,当点击保存的时候怎么统计次数,如果是点击直接打开或取消不算次数

------解决方案--------------------
这个要在js判断了  return false 不计算 return true 计算 (不知道对不对) 请告诉解答
------解决方案--------------------
在button里加个aplication吗,或者在一个表中加个字段,每次点击了button时就更新字段啊
------解决方案--------------------
public class DownloadHandler : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        string fileName = context.Request.QueryString["filename"].ToString();
        string filePath = "path of the file on disk"; //you know where your files are
        FileInfo file = new System.IO.FileInfo(filePath);
        if (file.Exists)
        {
            try
            {
                //更新数据库中的下载次数
            }
            catch (Exception)
            {
                //handl.
            }
            //return the file
            context.Response.Clear();
            context.Response.AddHeader("Content-Disposition", "attachment;&