[
  {
    "Id": "1430957",
    "ThreadId": "640127",
    "Html": "EDIT NOTE:<br />\n<br />\nI thought this was a problem with ZipFile.Save(to page context).<br />\n<h1>However, I rewrote the function below to convert the ZipFile to memorystream and then to binary array, and then download the binary array, and it gives the same error.  The ZipFile saves to disk just fine, so I don't think it's the file content.   Summary is that this is probably not a ZipFile issue, so doesn't really belong in this forum any more.</h1>\nThe code below works fine in a test site but fails in the main site (both are dev sites on the same machine).<br />\n<br />\nThe code below is set up to have a switch to write to disk or not.<br />\nA)  When it is set to write to disk, the disk write looks fine; well formed zip, opens fine, content is as expected.  However, when it then hits this statement:<br />\n<pre><code>            wrkZip.Save(context.Response.OutputStream)</code></pre>\n\nit jumps to the catch with this error:<br />\n<pre><code>            &quot;Cannot read that as a Zip file&quot;.  \n</code></pre>\n\nB)  when it is set to skip the write to disk, there is no error, but also no action, and the page goes &quot;dead&quot;, i.e. local js still works but callbacks don't.  It recovers with F5 on the browser.<br />\n<br />\nAgain, the exact same code including this:<br />\n<pre><code>           wrkZip.Save(context.Response.OutputStream)</code></pre>\n\nworks fine on the test site.<br />\n<br />\nI have a more extensive write up here:<br />\n<br />\n<a href=\"http://stackoverflow.com/questions/30925639/dotnetzip-download-works-in-one-site-not-another\" rel=\"nofollow\">http://stackoverflow.com/questions/30925639/dotnetzip-download-works-in-one-site-not-another</a><br />\n<br />\nWhere I describe how I replicated the exact same download data in both the test and main sites.<br />\n<br />\nHowever it seems to narrow down to the &quot;zip.save to download stream&quot; statement, and it's a mystery why it works in the test site but not the main site.<br />\n<br />\nAny suggestions on further diagnostics or fixes would be appreciated.<br />\n<br />\nThanks!<br />\n<pre><code>Public Sub ZipAndDownloadMemoryStreams(ByVal context As HttpContext) _\nImplements IHttpHandler.ProcessRequest\n    Dim rtn As String = &quot;&quot;\n\n    Try\n        Dim wrkAr As ArrayList\n        wrkAr = SC.ContentArrayForDownLoad\n        If wrkAr.Count = 0 Then\n            Dim wrkStop As Integer = 0\n            Exit Sub\n        End If\n\n        Dim wrkFS As ZipDownloadContentPair\n        Using wrkZip As New ZipFile\n            '----- create zip, add memory stream----------\n            For n As Integer = 0 To wrkAr.Count - 1\n                wrkFS = wrkAr(n)\n                wrkZip.AddEntry(wrkFS.FileName, wrkFS.ContentStream)\n            Next\n\n            context.Response.Clear()\n            context.Response.ContentType = &quot;application/force-download&quot;\n            context.Response.AddHeader( _\n                &quot;content-disposition&quot;, _\n                &quot;attachment; filename=&quot; &amp; &quot;_AMPTK_Export.zip&quot;)\n\n\n            '---- save context (initiate download)-----\n            Dim wrkFilePath As String = &quot;&quot;\n            If 1 = 1 Then\n                wrkFilePath = &quot;D:\\XYZ\\test.zip&quot;\n                wrkZip.Save(wrkFilePath)\n            End If\n\n            wrkZip.Save(context.Response.OutputStream)\n            wrkZip.Dispose()\n\n        End Using\n\n    Catch ex As Exception\n        Dim exmsg As String = ex.Message\n        Dim wrkStop As String = &quot;&quot;\n    End Try\nEnd Sub</code></pre>\n\n",
    "PostedDate": "2015-06-18T15:13:53.373-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]