The problem is that all supported files works properly (jpg, gif, png, pdf, doc, etc), but .docx files, when i download, it says corrupted and they need to be fixed by Office in order to be opened.
This is my code:
Response.AddHeader("Content-Disposition", "attachment;filename=\"" + filename + "\"");
Response.BinaryWrite(RptBytes);
stream.Dispose();
Response.Flush();
HttpContext.Current.ApplicationInstance.CompleteRequest();
I have got solution from some other site,
i.e
It turns out that the docx format needs to have Response.End() right after the Response.BinaryWrite instead of HttpContext.Current.ApplicationInstance.CompleteRequest()
Why are .docx files being corrupted when downloading from an ASP.NET page?
It's working fine but Response.End throws the exception as Thread was being aborted.