473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 7517
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Scott C. Reynolds | last post by:
I want to serve a PDF right to a web page (cannot link browser directly to PDF file). Stumbled across Response.WriteFile this morning. On my machine (XP Pro) this worked fine: private void...
1
by: Oct | last post by:
I have implemented an ISAPI filter to authenticate user download based on SQL data. It works great for all high speed users but it fail after 20-30 mins download on modem (yes, 56k!) user. The...
0
by: Thomas Andersson | last post by:
Hi, I have a problem with Response.TransmitFile. The server reset the connection after approx. 20 minutes and sometimes after 7-8 minutes when i try to download large files (400MB +) with...
1
by: Ryan Pedersen | last post by:
I have been trying to figure out how to transmit a file back to a user using the response.transmitfile or response.writefile method and just not having much success. I have a dell server running...
3
by: Buddy Ackerman | last post by:
I'm trying to write files directly to the client so that it forces the client to open the Save As dialog box rather than display the file. On some occasions the files are very large (100MB+). On...
4
by: Millhouse50 | last post by:
I am wondering how I can create like a dynamic hyperlink using C#. I am working with asp.net 2.0 and iis5 on windows 2000 server. I am creating a file in a program that I have which needs to be...
2
by: Michael D. Ober | last post by:
When I single step through the code below, it sends back the PDF file that is retrieved in the line fm.GetAccountPDF(...). When I run without single stepping, I get the master page for this page. ...
2
by: Nathan Sokalski | last post by:
I have an application in which I want to allow users to view certain files that are on the server, but not part of the application. To do this, I figured I would have ASP.NET read the files and...
1
by: =?Utf-8?B?V29vZGdub21l?= | last post by:
Hi, I have use the following code to transmit a file back to the browser that worked fine on a HTC_TTyN device running windows mobile 5.0. The code executes in the onclick event of a mobilelist...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.