locked
play mp3 file saved outside the root folder RRS feed

  • Question

  • User-2089623767 posted

    I hope someone can help me out with this one. I am working on a web application that plays mp3s. The mp3 player I'm using is PseudoMP3, a free .net mp3 player server control. My problem is that i'm trying to secure the mp3 files by saving them in a folder outside of my root, but I can't access the files from my application. My site is hosted by an ISP. My syntax for getting the files is:

    PseudoMP3Pick.Src = @"d:\websites\sampleDomain\mp3s\Superman.mp3";

    But it doesn't play the file. If I do a File.Exists, it says the file exists. My app just can't play it. Do I have to convert it to a different data type?

    The root directory is d:\websites\sampleDomain\httpdocs\. I'm using C#. Thanks for the help!

    Friday, October 27, 2006 7:29 PM

Answers

  • User-158764254 posted

    So the httphandler would handle accessing of files outside the rootfolder?

    yes.

    the httphandler can access files from anywhere you need even if those files arent directly exposed through a url.
    only the handler need to be accessible from a url

    i use this technique to secure software downloads, pdf downloads, image downloads etc...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, October 28, 2006 8:40 PM

All replies

  • User-158764254 posted

    you probably going to want to serve up the mp3 from a custom httphandler
    this way you can server it from anywhere on the server and you can add additional security checks

        PseudoMP3Pick.Src = @http://mywebsite.com/myApp/myHttpHandler.ashx?Tune=Superman.mp3;

    here's an article on file downloading that's probably relevant: http://msdn.microsoft.com/msdnmag/issues/06/09/WebDownloads/
    PseudoMP3Pick might be making byte range requests so it can start playing the file before its fully downloaded - i don't know as i've never used it.

    here's an article on httphandlers: http://www.15seconds.com/issue/020417.htm

    Friday, October 27, 2006 8:36 PM
  • User-2089623767 posted

    Hi mbanavige,

     Thanks for your reply. So the httphandler would handle accessing of files outside the rootfolder?

     Thanks again!

    Saturday, October 28, 2006 8:35 PM
  • User-158764254 posted

    So the httphandler would handle accessing of files outside the rootfolder?

    yes.

    the httphandler can access files from anywhere you need even if those files arent directly exposed through a url.
    only the handler need to be accessible from a url

    i use this technique to secure software downloads, pdf downloads, image downloads etc...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, October 28, 2006 8:40 PM
  • User-2089623767 posted

    Hi Mike,

     Sorry got busy with other projects, didn't get a chance to look into this too much. So when the httphandler accesses the files, how does it pass the file to an aspx page? for example I have an aspx page that needs access to a file outside the root, instead of the aspx accessing the file directly, I use the httphandler, right? How then can the httphandler return the file to the aspx page?

     Thanks for the help!

    oneill

    Thursday, November 16, 2006 11:30 AM