473,732 Members | 2,204 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Binar yWrite(...)" 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.AppendH eader("content-disposition", "attachment ;
filename=testfi le.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 2264
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.Binar yWrite(...)" 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.AppendH eader("content-disposition", "attachment ;
filename=testfi le.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
10149
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 do it. Is there script I can plug in without having to do asp or pl files? (Cobalt server does not allow these files) here is an example <a href="/muzak/wong.mp3"> as link
8
3312
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, www.publicpen.com/staengl, when I point my browser there, the browser, instead of showing me the index.htm pages like it should, it instead tries to download it as an object. Why? Below are the contents of index.htm. Does anyone see anythging...
0
1657
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 on click event should download an assembley from the server site to client ie. Opening page displays correctly with control when it does not include the
6
3757
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 getting its info from the content-length. I know this because I can test query against a apache box that does not return the content length however IE still knows the size of the files. What am i missing? Bryan
5
9149
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 that way, but i left it in anyway. little did i know it would cause a problem for a forced download routine i have. instead of downloading the .xls attachment, it tried to download the aspx file, and gave an error saying the file could not be...
5
12306
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. On Beta1, I am able to execute a particular page with no problem, that page opens up in the comes up just fine. On Win2kdev1, when I go to execute the same page, it opens a file download dialog and asks me whether I want to open or save the...
1
3273
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 get a 'File download-security warning' window popping up that ask if I want to download or open the file. It wants to download the aspx page itself , instead of the pdf file. I'd would like it to offer to open the pdf file, or avoid this security
1
2448
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 = -1) { @$a = filesize($file); if ($offset2 <= $offset || $offset2 < 1) $offset2 = $a - 1; if ($offset2 <= $offset || $offset < 0) $offset = 0; header("Content-Range: bytes $offset-$offset2/$a");
3
2071
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 following file types: doc, pdf, txt, jpg, gif. My testing was done on two PCs:
1
12813
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 button. when clicked, i call an ajax-request to a php-page where i dynamically create a ".pmp"-file. then it returns the name of the file. last, i open the file using document.location. here is my ajax request and the code to redirect my page....
0
8774
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9447
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9307
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9235
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9181
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.