【发布时间】:2020-12-29 14:32:30
【问题描述】:
我正在使用我的应用程序创建一个 docx 文件,但我被 Response.End() 卡住了。我收到此错误:
线程被中止
我收到此错误,但无论如何仍会创建该文件。当我尝试打开文件时,它总是损坏。我没有成功编写.docx 文件。请让我知道我做错了什么。
HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document; charset=utf-8";
HttpContext.Current.Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", "mydoc.docx"));
HttpContext.Current.Response.BinaryWrite(ourString);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
【问题讨论】:
-
请提供可执行代码。
标签: c# download response mime-types docx