Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Streaming Media to the client browser.

Hi guys.
I'm really new to ASP.NET. I'm planning on building an app for users to share their own music with other site members. I want to not allow people to download files directly from the url (ex. www.mysite.com/files/someGuysSong.mp3). I want the users to all go through a main download page and then the file would be retrived and sent to the client.(ex. www.mysite.com/Download.aspx?songID=1234 returns someGuysSong.mp3) I know how to do this in coldfusion quite easily, but it is proving to be much more difficult in asp.net.

Can anyone point me in the right direction? I can't seem to find anyone that has the slightest clue how to do this, which is strange. But hopefully you guys can shed some light on it!

Thanks!
-Morgan
[777 byte] By [twista] at [2007-11-11 9:59:52]
# 1 Re: Streaming Media to the client browser.
One option would be to store the files in a database rather than in the file system. That way it would not be possible for anyone to navigate to the URL, since the physical file would not exist on the Web server. For details on this approach, see http://msdn.microsoft.com/msdnmag/issues/06/09/WebDownloads/ .

Another option, assuming you have full access to the Web server, is to store the files somewhere outside the webroot, such as, say, c:\files. Grant the ASPNET user account access to c:\files; your code behind will be able to read the files and return them to the user, but the directory will not be accessible to the Web application.
Phil Weber at 2007-11-11 23:12:12 >
# 2 Re: Streaming Media to the client browser.
Thanks for the reply Phil.
I actually had already planned on storing the files outside the webroot. What I was actually looking for was what objects I would need to use to in the code behind file to retrieve the files. I'm sure in the end it revolves around one single object, but every problem I've had to solve so far has required multiple objects to complete and the chain can be a little difficult to find :)
twista at 2007-11-11 23:13:12 >