Why are .docx files being corrupted when downloading from an ASP.NET page?

前端 未结 8 941
长发绾君心
长发绾君心 2020-12-03 05:09

I have this following code for bringing page attachments to the user:

private void GetFile(string package, string filename)
{
    var stream = new MemoryStre         


        
8条回答
  •  抹茶落季
    2020-12-03 05:24

    I also ran into this problem and actually found the answer here: http://www.aspmessageboard.com/showthread.php?t=230778

    It turns out that the docx format needs to have Response.End() right after the Response.BinaryWrite.

提交回复
热议问题