I am trying to serve zip files to people so that they are given the Open, Save, Cancel dialog. I have got this code to work with Firefox, but IE somehow corrupts the file and it is unreadable on the client - though the same size as created on the server. Here is the code:
dim filename as string ="123456789.zip"
Response.ClearHeaders() ' just wanted to be absolutely sure that the page had not set anything and that there is no content from the page
Response.ExpiresAbsolute = Nothing
Response.CacheControl = ""
Response.AppendHeader("content-disposition", "attachment; filename=""" & filename & """")
Dim g As Integer = fi.LengthResponse.ContentType = "application/zip" 'tried application/x-zip-compressed too but makes no difference
'Dim fi As New FileInfo(filename)
'Response.AppendHeader("Content-Length", g.ToString) 'adding this made no difference
Response.WriteFile(server.mappath("/myzipdir/" & filename)
The headers that IE receives:
HTTP/1.1 200 OK
Date: Wed, 31 May 2006 09:18:32 GMT
Expires: Wed, 31 May 2006 09:18:32 GMT
content-disposition: attachment; filename="123456789.zip"
Via: 1.1 cbs-cache1 (NetCache NetApp/5.6.2R1)