469,957 Members | 2,628 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,957 developers. It's quick & easy.

Help with Response.WriteFile/TransmitFile

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

Nov 19 '05 #1
3 7336
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.

"je******@yahoo.com" wrote:
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

Nov 19 '05 #2
Brad,

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

thanks
jeffpriz

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

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Scott C. Reynolds | last post: by
reply views Thread by Thomas Andersson | last post: by
1 post views Thread by Ryan Pedersen | last post: by
3 posts views Thread by Buddy Ackerman | last post: by
4 posts views Thread by Millhouse50 | last post: by
2 posts views Thread by Nathan Sokalski | last post: by
1 post views Thread by =?Utf-8?B?V29vZGdub21l?= | last post: by
reply views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.