I am unable to stream a word document that I create on the fly down to the browser. I am constantly getting a message from Microsoft Word that the document is corrupt.
(This is using OpenXML SDK v 2.10.0 and .Net Core v2.2)
I know this has been answered but I wanted to throw out another option. It is correct that trying to send a stream back in File() like below will result in a corrupt document:
MemoryStream updateStream = new MemoryStream();
wordDocument.Save();
wordDocument.Clone(updateStream);
return File(updateStream, "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
`
A super simple alternative/workaround would be to simply convert your stream to a byte[] like below and it will result in a working word docx
MemoryStream updateStream = new MemoryStream();
wordDocument.Save();
wordDocument.Clone(updateStream);
return File(updateStream.ToArray(), "application/vnd.openxmlformats-officedocument.wordprocessingml.document");