Aspose.Words 直接写response导出docx文档显示文件已损坏需要修复的解决办法

使用Aspose.Words的Document.Save(HttpResponse response, string fileName, ContentDisposition contentDisposition, Aspose.Words.Saving.SaveOption saveOption)方法,将Document直接写入response时,需要加Response.End();

Document doc = new Document(postedFile.InputStream);
doc.Save(Response, dstFileName, ContentDisposition.Inline, SaveOptions.CreateSaveOptions(dstFormat));
// Required. Otherwise DOCX cannot be opened on the client (probably not all data sent
 // or some extra data sent in the response).
Response.End();

请注意注释部分!!

原文地址:https://www.cnblogs.com/drsniper/p/4814961.html