Dim file As New System.IO.FileInfo(filefullpath)
Response.Clear()
Response.ClearHeaders()
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(file.FullName, System.Text.Encoding.UTF8))
Response.AppendHeader("Content-Length", file.Length.ToString())
Response.WriteFile(file.FullName)
Response.End()以上代码没有任何错误,在单个页面执行的时候也可以输出文件。但在框架网页中(frameset)无效,并且在请求这个页面的时候会产生多次请求(请求这个页面一次就会进入无限对这个页面的请求)用Try 调试会在WriteFile中Catch到"线程正被中止",百思不解,望高手指点

解决方案 »

  1.   

    增加:
    if (!IsPostBack){
        //code here}
      

  2.   

    改Response.BinaryWrite();试试呢
      

  3.   

    增加一个空的页面,
    在load中添加:
    Response.Clear()
    Response.ClearHeaders()
    Response.ContentType = "application/octet-stream"
    Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(Request[strFileName], System.Text.Encoding.UTF8))
    Response.AppendHeader("Content-Length", file.Length.ToString())
    Response.WriteFile(file.FullName)
    Response.End()将请求转到这个页面。应该可以。
      

  4.   

    我正在试用其它方法,弹出新窗口这个会影响客户情绪. try!!!!