【发布时间】:2013-12-16 07:43:28
【问题描述】:
我正在尝试从数据库下载 word 文档 (.docx)。
所以我在下载函数的末尾使用了以下代码
Response.BinaryWrite(MyByte)
Context.ApplicationInstance.CompleteRequest()
但它会将不需要的内容写入我的 word 文件,因此每次打开文件时都会抛出错误。
文件已损坏,无法打开
我用谷歌搜索了这个问题,我得到了 Use Response.End() 而不是 Context.ApplicationInstance.CompleteRequest()
但是 Response.End 抛出错误,因为线程被中止。并且文件完美打开。
【问题讨论】:
-
最后我通过添加 Response.AddHeader("content-length", mytBytes.Length.ToString()) 得到了这个解决方案
标签: .net vb.net download response