Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > badly formatted .mp3 when forcing a download in ASP using Content-Disposition...

Reply
Thread Tools

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

 
 
Mike McCarthy
Guest
Posts: n/a
 
      04-16-2004
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
 
Reply With Quote
 
 
 
 
Ray at
Guest
Posts: n/a
 
      04-16-2004
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

"Mike McCarthy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) m...
> 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"
> %>
>


>
> 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.



 
Reply With Quote
 
 
 
 
Aaron Bertrand [MVP]
Guest
Posts: n/a
 
      04-16-2004
Is it remotely possible that the MP3 file is, in fact, corrupt?

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"Mike McCarthy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) m...
> 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



 
Reply With Quote
 
Michael McCarthy
Guest
Posts: n/a
 
      04-16-2004
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.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
Michael McCarthy
Guest
Posts: n/a
 
      04-16-2004
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...



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
Aaron Bertrand [MVP]
Guest
Posts: n/a
 
      04-16-2004
> 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.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


 
Reply With Quote
 
Ray at
Guest
Posts: n/a
 
      04-16-2004
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

"Michael McCarthy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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...
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
Ray at
Guest
Posts: n/a
 
      04-16-2004
Also take a look here: http://www.aspfaq.com/5003

Ray at home

"Michael McCarthy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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...
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
Michael McCarthy
Guest
Posts: n/a
 
      04-16-2004
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
Ray at
Guest
Posts: n/a
 
      04-16-2004
Not a problem. We all learn this way. :]

"Michael McCarthy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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


 
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
Forcing Download of File Appends HTML from Download Page to Downloaded File? Brett Kelly ASP .Net 1 06-16-2006 04:05 AM
Message received was unexpected or badly formatted SleepingRabbit ASP .Net Web Services 0 02-07-2005 07:03 AM
badly struck! how to pass values from asp to excel VbUser25 ASP General 0 01-27-2005 03:43 AM
Sun C++ : Unexpected type Badly formed expression using String Gil C++ 1 12-24-2003 08:56 AM
Forcing a file download w/ a button Do ASP .Net 1 11-28-2003 04:02 AM



Advertisments