locked
Stream/download Text as File to browser RRS feed

  • Question

  • User821732229 posted
    Hi! Wondering if anyone out there can help me on this. I am attempting to enchance an existing web app that I've written in C#. I have an application that allows users to listen to mp3 files off a server using Winamp/RealAudio/MediaPlayer. Currently, the app allows users to listen to mp3s by reading a playlist file (*.m3u ..etc..) downloaded from the web server from a Response.redirect . Now, what I want to do is to elimate any creation/saving of playlist files on the web server from the app and have a user stream/download text as a file to user's browser (no file present). I know this can be done but would like some guidance on the code to do this. Thank you for any assistance out there.
    Thursday, March 25, 2004 11:49 AM

All replies

  • User-1391363652 posted
    Take a look at the MemoryStream class. Currently we use it to generate images and stream them to the client. No images are actually saved on the disk so we don't have to worry about cleaning up temporary files. MemoryStream has a very helpful method---WriteTo (). It writes stream contents to another stream. In our case we redirect our temporary image right to the response stream: MemoryStream memStream = new MemoryStream ((byte [])arr); memStream.WriteTo (app.Context.Response.OutputStream); memStream.Close (); I think you've got the rest in place already---setting up the correct Response.ContentType and Response.StatusCode.
    Thursday, March 25, 2004 5:06 PM
  • User-232223085 posted
    I would also recommend using the follow code as well as the memory stream Response.Content-Type = "audio/x-mpegurl" Response.AddHeader("content-disposition","attachment: filename=filename.m3u") The top line tells the browser to treat the file is receives as an audio file even though it requested a file with an aspx extension. Then second line tells it to keep the file as its own distinct file and not to display it inline in the browser.
    Thursday, April 1, 2004 1:10 PM
  • User354694065 posted
    The problem you will have with this, is if you are creating dynamic playlists Media player 9 will disallow the expanding of playlists.... I've ran across this as it was added as a "feature" for content providers.... It is a really annoying bug, I'm working on writing a HTTPHandler to see if i can get this working....
    Tuesday, April 13, 2004 12:21 PM
  • User2082958195 posted
    Hi, I am implementing a similar project with images. I want to make images available for user to d/l with different DPI options. I am wondering how I can let user to specify the download path? As Milan’s post, I am trying the MemoryStream but still not sure how it works. Any help will be greatly appreciated. Thanks,
    Tuesday, April 13, 2004 8:12 PM