I am setting up new servers for Windows Server 2019. This runs the same IIS configuration, bound to the same directory and the same executable. We only installed IIS as per the documentation I set up a few years ago. For some kind of reason, despite everything working fine on the new OS, when we download a .docx or a .xlsx file from the website, it ends up corrupted. I verified the MIME types on IIS and everything for those two file extensions are identical. I am wondering what else could be a factor.
The download is done via the .NET Transmit support. Basically, the content type is adjusted as per the extension. As I mentioned, this is the same executable. This is something in IIS or something that has to be installed which could affect IIS. I see ASP.Classic was installed in the Windows Server 2008. I do not believe we would need that support on Windows Server 2019 for a download of a Microsoft Office file to work.
Here is an example of how the transmit works for a Microsoft Word file (the real code is generic, I just changed this here so you can see the proper ContentType generated when this is a docx file:
oProcess.oResponse.Clear()
oProcess.oResponse.ClearContent()
oProcess.oResponse.ClearHeaders()
oProcess.oResponse.Charset = cCharset
oProcess.oResponse.ContentType = "application/ms-word"
oProcess.oResponse.AddHeader("Content-Disposition", "attachment;filename=" + lcFileNameDestination)
oProcess.oResponse.AddHeader("Content-Length", lnSize.ToString())
oProcess.oResponse.ContentEncoding = System.Text.Encoding.GetEncoding(cContentEncoding)
oProcess.oResponse.TransmitFile(cFile)
oProcess.oResponse.End()