I solved my own mystery of the SSL Download Disaster: Add .ClearContents() and .ClearHeaders() and Remove .Clear() also ensure that you do not use .End() as this will cause a threading error which can be handled with a Try...Catch, but better to use HttpContext.Current.ApplicationInstance.CompleteRequest() which does not cause the same threading error.
This code is all you need to get around the problem I would image any DNN 4.4+ developer will have when doing Save type downloads (with compression on) under SSL: Note that if you use the HttpSetCacheability then set it to Public only. Below is all the code you need to make it work in most cases. Below that I put my complete code which will optimize the process in most cases.
With Page.Response
.ClearContent()
.ClearHeaders()
.ContentType = "text/csv" ' "application/ms-excel" '"application/x-zip-compressed"
.AddHeader("content-disposition", "attachment; filename=Test1.csv")
.OutputStream.Write(byteArray, 0, byteArray.Length)
HttpContext.Current.ApplicationInstance.CompleteRequest()
End With
With Page.Response
Try
.ClearContent()
.ClearHeaders()
.Charset = "iso-8859-1"
.Cache.SetCacheability(HttpCacheability.Public)
.ContentType = "text/csv"
.AddHeader("content-disposition", "attachment; filename=Test1.csv") 'sFilename
.Buffer = True
.AddHeader("Content-Length", byteArray.Length.ToString())
.AddHeader("Accept-Ranges", "bytes")
.AddHeader("Accept-Header", byteArray.Length.ToString())
.OutputStream.Write(byteArray, 0, byteArray.Length)
.OutputStream.Flush()
HttpContext.Current.ApplicationInstance.CompleteRequest()
Page.Controls.Clear()
Catch ex As Exception
HttpContext.Current.ApplicationInstance.CompleteRequest()
.StatusCode = 404
.StatusDescription = "Requested resource not found"
End Try
End With