473,395 Members | 1,679 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,395 software developers and data experts.

File download problem - content-disposition as attachment breaks p

GRE
I'm hoping someone can help with this problem; I've seen only a handful of
postings related to it, but with no clear resolution.

I have an ASP.NET 1.1 page that downloads requested files via the
"Response.BinaryWrite(...)" method. The problem is that the page is
dynamically built, and after the download completes all javascript functions
suddenly break or exhibit unpredictable behavior.

I've traced the issue down the use of the "attachment" attribute when
setting the Content-Disposition header. For example:

Reponse.AppendHeader("content-disposition", "attachment;
filename=testfile.txt");

.... will download the file intact, but the page will lose all of its
javascript references.
I'm also adding the obligatory "Response.End()" statement after the last
"Response.Flush()".

One odd note is that omitting the "attachment" attribute altogether will
allow for some files to download and NOT break the page afterwards. However,
this is not reliable for types that could be rendered to the browser (.txt,
etc.).

Has anyone else come across this problem, and is there any consensus on what
might be causing it? Any feedback, resources, etc., here would be greatly
appreciated.

GRE
Nov 18 '05 #1
1 2246
On 8/19/2004 4:17 PM, GRE wrote:
I'm hoping someone can help with this problem; I've seen only a handful of
postings related to it, but with no clear resolution.

I have an ASP.NET 1.1 page that downloads requested files via the
"Response.BinaryWrite(...)" method. The problem is that the page is
dynamically built, and after the download completes all javascript functions
suddenly break or exhibit unpredictable behavior.

I've traced the issue down the use of the "attachment" attribute when
setting the Content-Disposition header. For example:

Reponse.AppendHeader("content-disposition", "attachment;
filename=testfile.txt");

... will download the file intact, but the page will lose all of its
javascript references.
I'm also adding the obligatory "Response.End()" statement after the last
"Response.Flush()".

One odd note is that omitting the "attachment" attribute altogether will
allow for some files to download and NOT break the page afterwards. However,
this is not reliable for types that could be rendered to the browser (.txt,
etc.).

Has anyone else come across this problem, and is there any consensus on what
might be causing it? Any feedback, resources, etc., here would be greatly
appreciated.

GRE

Hmmm, are you saying you want to have some Javascript in the browser, in
the same page/frame that is writing the file out? That can't happen,
you can't mix MIME types; either you are writing HTML to the browser, or
sending the attachment in 1 response...Are you using frames, or what is
the page layout here?

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: BOHICA | last post by:
I would like on my page when users click one of my mp3 files for the dialog box to pop up so they can choose to save the file to disk instead of trying to open through IE, but the dang thing won't...
8
by: lawrence | last post by:
Under the domain publicpen.com I've several dozen sites in subdiretories, such as www.publicpen.com/honenbeger. I've no trouble with any of these sites. But under one, which I put in yesterday,...
0
by: Rea Peleg | last post by:
link to configuration file prevents user control download to internet explorer Hi I have a simple web application which consists an opening html page with a (windows form user) control which...
6
by: Bryan Martin | last post by:
Ok im trying to figure out how internet explorers file download box always seem to at least come close to knowing the exact file size/time to download. From what I can tell its getting its not...
5
by: Tim_Mac | last post by:
hi, i read that by adding the following code to by aspx pages, it would not store temporary internet files: Response.Cache.SetCacheability(HttpCacheability.NoCache); it didn't actually work...
5
by: Neil Rossi | last post by:
I have an issue with a particular ASP page on two web servers. Let's call these servers Dev1 and Beta1. Both Servers are running IIS 5, Windows 2000 SP4 with "almost" all of the latest patches. ...
1
by: Cindy H | last post by:
Hi I used the code below to automatically open a pdf file when the user clicks on a menu option. It works great on local machine, but when I uploaded it to hosting site and then tried it, I...
1
by: Chameleon | last post by:
I want to send a static file, via php to browser with ability to resume download. This is the code: -------------------------------------------- function send_file($file, $offset = 0, $offset2 =...
3
by: rafi | last post by:
Hi, I developed a website using php5 & mysql5. One of its features is the ability of users to upload files to the server, and allow other users to view these files. I allow uploading the...
1
Ciary
by: Ciary | last post by:
hey all, i have another problem. basically the question is: how do i make sure a file is downloaded instead of opened? but i'll explain the situation. i'm trying to download a file using a...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.