File download problem - content-disposition as attachment breaks p

G

Guest

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
 
C

Craig Deelsnyder

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,078
Latest member
MakersCBDBlood

Latest Threads

Top