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到"线程正被中止",百思不解,望高手指点
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到"线程正被中止",百思不解,望高手指点
if (!IsPostBack){
//code here}
在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()将请求转到这个页面。应该可以。