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

Discussion in 'ASP General' started by Mike McCarthy, Apr 16, 2004.

  1. 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
     
    Mike McCarthy, Apr 16, 2004
    #1
    1. Advertising

  2. Mike McCarthy

    Ray at Guest

    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" <> wrote in message
    news:...
    > 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.
     
    Ray at, Apr 16, 2004
    #2
    1. Advertising

  3. Is it remotely possible that the MP3 file is, in fact, corrupt?

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


    "Mike McCarthy" <> wrote in message
    news:...
    > 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
     
    Aaron Bertrand [MVP], Apr 16, 2004
    #3
  4. 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!
     
    Michael McCarthy, Apr 16, 2004
    #4
  5. 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!
     
    Michael McCarthy, Apr 16, 2004
    #5
  6. > 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/
     
    Aaron Bertrand [MVP], Apr 16, 2004
    #6
  7. Mike McCarthy

    Ray at Guest

    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" <> wrote in message
    news:...
    > 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!
     
    Ray at, Apr 16, 2004
    #7
  8. Mike McCarthy

    Ray at Guest

    Also take a look here: http://www.aspfaq.com/5003

    Ray at home

    "Michael McCarthy" <> wrote in message
    news:...
    > 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!
     
    Ray at, Apr 16, 2004
    #8
  9. 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!
     
    Michael McCarthy, Apr 16, 2004
    #9
  10. Mike McCarthy

    Ray at Guest

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

    "Michael McCarthy" <> wrote in message
    news:...
    > 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
     
    Ray at, Apr 16, 2004
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ben
    Replies:
    0
    Views:
    1,089
  2. =?Utf-8?B?R1JF?=
    Replies:
    1
    Views:
    3,437
    Craig Deelsnyder
    Aug 20, 2004
  3. Replies:
    2
    Views:
    408
  4. Bob Jones
    Replies:
    2
    Views:
    527
    Bob Jones
    Nov 13, 2007
  5. SleepingRabbit

    Message received was unexpected or badly formatted

    SleepingRabbit, Feb 7, 2005, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    432
    SleepingRabbit
    Feb 7, 2005
Loading...

Share This Page