badly formatted .mp3 when forcing a download in ASP using Content-Disposition...

M

Mike McCarthy

Hello all,

I wanted to see if anyone was having the same problems as me playing
an .mp3 file after forcing a download from and IIS server using ASP
and the following code:

<%
Response.ContentType = "audio/mpeg"
Response.AddHeader "Content-Disposition", "attachment;
filename=test.mp3"
%>

I double-checked that the web server's MIME type setting match the
..mp3 extenstion with the audio/mpeg ContentType. The download prompt
box comes up correctly, and I save the MP3 file to disk.

But when I try to open it using Windows Media Player or Quicktime,
both programs tell me it cannot recognize the file, and Windows Media
player just crashes.

I double-checked the .mp3 file that was saves, it doesn't contain zero
bytes, or have any hidden extensions past the .mp3 extension... for
all intensive purposes, I am doing this 100% correctly... I've
successfully tried the same code above using a Word document, and it
works just find. I've also tried running it on my localhost machine,
but I get the same error for the MP3.

If anyone has any ideas, I would much appreciate your input.

Thanks much,
Mike McCarthy
 
R

Ray at

What code are you using to feed the data to the client? Are you
adodb.streaming it? Can you show that code?

Ray at home
 
M

Michael McCarthy

Aaron,

I double-checked the MP3 played on my system just fine before
downloading it to my system via the http header adjustments mentioned in
my previous post...

so I know the MP3 file is good file and is playable by Media Media
Player and Quicktime.
 
M

Michael McCarthy

Thanks for the quick reply Ray!

I haven't used ADODB.Streaming before, I am not too sure what it is...

I am simply forcing a download prompt to IE by sending it the
appropriate headers... all the code to see is already in my previous
post. I assumed b/c I had this code working properly with a Word
document, that an .mp3 should be no big deal.

I don't think I need to stream the file to the client, I am not trying
to play the file directly, I am trying to get the download prompt forced
on IE so a user can save the .mp3 to their hard drive and listen to it,
burn it, whatever...
 
A

Aaron Bertrand [MVP]

I am simply forcing a download prompt to IE by sending it the
appropriate headers... all the code to see is already in my previous
post. I assumed b/c I had this code working properly with a Word
document, that an .mp3 should be no big deal.

That doesn't make sense. The browser doesn't know where to stream the bits
from unless you tell it somehow. Just adding the header isn't enough. See
http://www.aspfaq.com/2161 for a working example.
 
R

Ray at

So, then, what does the user actually click on to download this? A href to
a .asp file or to a .mp3 file that you opened in a text editor and added asp
code to? 8-O

What comes after the code that you posted? Something has to be there!

Ray at home
 
M

Michael McCarthy

Ray,

First and foremost, I aplogize for posting this question to multiple
newsgroups if that's what your "Please don't multi-post" link to me was
about... I THINK that is what I did wrong in this case. Next time, I'll
stick to one... I didn't realize how quickly people read this stuff and
help! I am blown away.

Anyway, the user Aaron sent me a link to this article:
http://www.aspfaq.com/2161
I don't know what I was thinking, setting up the headers for a Save As
and then never sending the data down... But now I know how it's done. I
used the code from that article, and my downloads work now!

Thanks so much for the help, it's nice to know there is still a
responsive community of programmers out there when all else fails.

Take care,
Mike
 
R

Ray at

Not a problem. We all learn this way. :]

Michael McCarthy said:
Ray,

First and foremost, I aplogize for posting this question to multiple
newsgroups if that's what your "Please don't multi-post" link to me was
about... I THINK that is what I did wrong in this case. Next time, I'll
stick to one... I didn't realize how quickly people read this stuff and
help! I am blown away.

Ray at home
 

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

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top