Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Download of .docx and .xlsx are corrupted
Message
From
15/12/2020 21:43:04
 
 
To
All
General information
Forum:
ASP.NET
Category:
Installation, Setup and Configuration
Title:
Download of .docx and .xlsx are corrupted
Miscellaneous
Thread ID:
01677598
Message ID:
01677598
Views:
43
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()
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Reply
Map
View

Click here to load this message in the networking platform