We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Download docx - Corrupt file warning

I’m generating a docx file in a .net backend by reading a docx template and writing to it. Then I return it to the frontend client by saving the bytestream to a byte[] and receiving it as an blob.

However, my issue is that I receive a “Corrupt file warning, do you want to try to restore it?” in Word when I open the downloaded docx file. The file is restored and working as intended though.
I don’t get the Corrupt file error if I save the generated file directly to disk.

How do i solve this?

  • Frontend: React with superagent.


You can resolve the problem with DOCX by simply adding Response.End() after sending document to client browser. For some reasons, when you save a DOCX document to client browser, content of web page is added at the end of the document, you can see this if you open your DOCX document in any binary editor. That is why Microsoft Word cannot open this document. If you add Response.End(), content of web page will not be added and document will be valid. Hope, this helps.

Thanks for the help, however i manage to solve it by using ToArray() on my MemoryStream instead of GetBuffer.


Good to know that you have sorted it out when using ToArray() method. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.