asp.net如何实现Response下载文件不关闭父窗口? 是客户端设置呢,还是在.cs里处理呢? 谢谢!!有的机器运行asp.net点击打开文件不关闭父窗口,有的机器调用asp.net页面,点击打开文件关闭父窗口?怎么实现都不关闭父窗口?
HttpContext.Current.Response.Clear();
     HttpContext.Current.Response.AddHeader("Content-Disposition","attachment;filename=" + HttpUtility.UrlEncode(fi.Name));
     HttpContext.Current.Response.AddHeader("Content-Length",fi.Length.ToString());
     HttpContext.Current.Response.ContentType="application/octet-stream";
     HttpContext.Current.Response.WriteFile(fi.FullName,0,fi.Length);
     HttpContext.Current.Response.Flush();

解决方案 »

  1.   

     Response.Clear();
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
                    Response.AddHeader("Content-Length", file.Length.ToString());
                    Response.ContentType = "application/octet-stream";
                    Response.Filter.Close();
                    Response.WriteFile(file.FullName);
                    Response.End();
    用我的试试。
      

  2.   

    Response.Clear(); 
    Response.AddHeader("Content-Disposition",   "attachment;   filename="   +   file.Name); 
    Response.AddHeader("Content-Length",   file.Length.ToString()); 
    Response.ContentType   =   "application/octet-stream"; 
    Response.Filter.Close(); 
    Response.WriteFile(file.FullName); 
    Response.End(); 
      

  3.   

    例如下载word文件,弹出窗口后,点打开,文件打开了,但后面的页面,也就是父页面关闭了!有的机器不关闭,有的机器就关闭,我要求不关闭父页面
      

  4.   

    假如我有一个页面a.aspx 上面有一个下载文件按钮,按钮事件  关键内容 如下:
    Response.Clear();   
    Response.AddHeader("Content-Disposition",       "attachment;       filename="       +       file.Name);   
    Response.AddHeader("Content-Length",       file.Length.ToString());   
    Response.ContentType       =       "application/octet-stream";   
    Response.Filter.Close();   
    Response.WriteFile(file.FullName);   
    Response.End();   
    当我点击按钮时,弹出窗口,窗口上面显示打开或者保存,关闭信息,当你点击打开或保存文件时,父窗口就关闭,我要求这个窗口不关闭,???如何实现,无论是客户端设置还是服务器端代码,只要实现就好!
      

  5.   

    Response.Clear();       
    Response.AddHeader("Content-Disposition",               "attachment;               filename="               +               file.Name);       
    Response.AddHeader("Content-Length",               file.Length.ToString());       
    Response.ContentType               =               "application/octet-stream";       
    Response.Filter.Close();       
    Response.WriteFile(file.FullName);       
    Response.End();       
    就是楼上的这个 我用过  这么多朋友都告诉你了
      

  6.   

    一般的情况下都是不关闭父窗口的.csdn论坛的下载和其他的论坛几乎都是这样.
    要是真的如你说的,你就做个弹出窗口
      

  7.   

    楼主解决了没有,我也遇到了相同的问题,要是解决了发个邮件给我。谢谢了。
    [email protected]
      

  8.   

    虽然已经结贴了,但是我也是在遇到这个问题的时候找到了解决方案,特把方案放上。
    在页面加载事件里为按钮添加一个属性
    button1.Attributes.Add("onclick", "this.form.target='_blank'");