Help with Response.WriteFile/TransmitFile

  • Thread starter Thread starter jeffpriz
  • Start date Start date
J

jeffpriz

I'm have a situation where I need to put a download link/button on a
page, where the file to be downloaded does not exist on our webservers
.... So I'm using Response.WriteFile (i've also tried
Response.TransmitFile) to put the file into the response..

My trouble is with a Zip file.. The user gets propmpted to Open or Save
etc.. If they clicks save, the file saves just fine.. no problem... If
they click Open, their Zip program will open, with the file, except,
the contents of the zip are not there.. It opens as an empty zip!

my code looks something like this:
Dim thisFile As System.IO.FileInfo

thisFile = New FileInfo(file Location)
Response.Clear()

Response.AddHeader("Content-Length",
thisFile.Length.ToString)


Response.ContentType = "application/x-zip-compressed"

Response.AddHeader("Content-disposition", "filename=" &
thisFile.Name)


Response.TransmitFile(thisFile.FullName)
'Response.WriteFile(thisFile.FullName)

Response.End()

I've tried a ContentType of "application/x-zip-compressed", also, I've
just tried ContentType "application/none".. with no luck.

Am I missing a Header somewhere to tell the client how to open the
file?

thanks

jeffpriz
 
I have run into a similar problem with DOC and PDF files. The problem was
related to the content-expiration setting on the web site being "immediately"
.. Setting it to 1 minute cured it.
 
Brad,

Thanks for the reply, so this was an IIS setting change? or a
Code-change.. ?

thanks
jeffpriz
 
Hmm.. Set IIS' "Enable Content Expiration" to expire after 1 min, 1
hour, 1 Day, none had any effect...
 
Back
Top