我在2003中用如下代码实现附件下载,程序执行后,当弹出提示保存信息时,点击保存,打开,或取消,文件下载了,但IE自动关闭了,请问这是怎么回事,谢谢if(Request.QueryString["id"] != null)
{
string fid = Request.QueryString["id"].ToString();
SqlDataReader sdr = SchoolOA.BusinessLayer.Work.WorkDownLoad(new Guid(fid));
sdr.Read();
string path = Server.MapPath(sdr["WorkDocContent"].ToString());
System.IO.FileInfo file = new System.IO.FileInfo(path);
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name));
Response.ContentEncoding=System.Text.Encoding.UTF8;
sdr.Close();
//Response.Flush();
Response.WriteFile(file.FullName);
//Response.Redirect(path);
Response.End();
{
string fid = Request.QueryString["id"].ToString();
SqlDataReader sdr = SchoolOA.BusinessLayer.Work.WorkDownLoad(new Guid(fid));
sdr.Read();
string path = Server.MapPath(sdr["WorkDocContent"].ToString());
System.IO.FileInfo file = new System.IO.FileInfo(path);
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name));
Response.ContentEncoding=System.Text.Encoding.UTF8;
sdr.Close();
//Response.Flush();
Response.WriteFile(file.FullName);
//Response.Redirect(path);
Response.End();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货