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

点击下载功能
点击,转到一般处理程序,在一般处理程序中将数据库中二进制流转换后,实现下载
public void ProcessRequest(HttpContext context)
        {
            Guid FileID = Guid.Parse(context.Request.Params["fileid"].ToString());

            XML_SYS_FILEEntity file = new XML_SYS_FILEEntity() { XFL_ID = FileID };
            if (file.RemotingInitEntity<SYSTEMLink>())
            {
                string FileName = System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(file.XFL_FILE_NAMEDisplayValue + file.XFL_FILE_EXTEND_NAMEDisplayValue));
                string leng = file.XFL_FILE_LENGTHDisplayValue;

                context.Response.Clear();
                context.Response.ContentType = "application/octet-stream";
                context.Response.AddHeader("Content-Disposition", "attachement;filename=" + file.XFL_FILE_NAMEDisplayValue);
                context.Response.AddHeader("Content-Length", leng.ToString());
                context.Response.BinaryWrite(file.XFL_FILE_BYTES);
                context.Response.End();
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
但是点击后便直接打开了文件

------解决方案--------------------
 Response.Clear();
            Response.ClearHeaders();
     &n