Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > File download problem - content-disposition as attachment breaks p

Reply
Thread Tools

File download problem - content-disposition as attachment breaks p

 
 
=?Utf-8?B?R1JF?=
Guest
Posts: n/a
 
      08-19-2004
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
 
Reply With Quote
 
 
 
 
Craig Deelsnyder
Guest
Posts: n/a
 
      08-20-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Download breaks after win03 SP1 install Ayrin ASP .Net 0 02-22-2007 01:09 PM
problem with code download file - two window file download Sam -- ASP .Net 2 03-17-2005 04:20 PM
File upload/download from database. Download appends aspx page to end of file Ryan Taylor ASP .Net 2 11-10-2004 08:31 PM
Download file dialogue appears twice using Content-Disposition 'attachment' submitted from a form ben ASP .Net 0 07-07-2004 10:26 AM



Advertisments