Help with Response.WriteFile/TransmitFile

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
 
G

Guest

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.
 
J

jeffpriz

Brad,

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

thanks
jeffpriz
 
J

jeffpriz

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top