Ok, a quick google of transmits file and corruption?
Well, turns out - common problem.
First up, PDF and a lot of file formats have some "wiggle" room in terms of the file size in bytes sent. However, some binary commercial programs? They don't tolerate a SLIGHT change in the file size saved, or sent. In fact, in the old days, FTP would often cause this issue (the exact file size and length was padded as a multiple of 256. As noted, most software does not care but some does!!!
Also, be careful. Reponse.Flush, and Response.End have HUGE different meanings here.
Don't just throw mud against the wall - hope this works. Figure out WHICH one is more appropriate for your needs.
So, the solution suggested for this issue? INCLUDE the file size in the headers for the download.
Try this code :
If File.Exists(strInternalFile) Then Dim iFileInfo As New FileInfo(strInternalFile) strConType = MimeMapping.GetMimeMapping(strInternalFile) Response.Clear() Response.ContentType = strConType Response.AppendHeader("Content-Length", iFileInfo.Length.ToString) Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(strInternalFile)) Response.TransmitFile(strInternalFile) Response.End() Else ' send jquery toast message - file not found. ' grab control few colums left of the "right most image button" ' We just need a good toast popup position (if I use image button - toast message is too far right side ' so grab the Qty column - anything a few columns to the left is fine
it should be Mr. Obvious in above, but that Response.End is the LAST LINE AND ONLY line of code to be executed here - anything else after (more code) should NOT exist, nor be required BUT ALSO NOT RUN!!!!!
In other words, because we are dealing with the page life cycle, then MUCH concern as to what occurs in the page load event needs caution. (any code that loads up the page, the grid, the tree view or ANYTHING else needs to be placed inside of the page load even wrapped in the ALL super duper important Is not page post back).
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If IsPostBack = False Then ' code here to load gride, or tree view etc. - ONLY FIRST page load!! End if