Exemplo n.º 1
0
        public ActionResult Download(int id)
        {
            if (id > 0)
            {
                var material = jlService.GetMaterial(id);

                if (material != null)
                {
                    // 下载量加1
                    jlService.IncrementPageViews(id);

                    var filePath = Server.MapPath(material.FileName);
                    var mime     = MimeMapping.GetMimeMapping(filePath);

                    var bytes = GetFile(filePath);
                    return(File(bytes, mime));
                }
            }

            return(HttpNotFound());
        }