Making a no-cache mp3 serving script in VB

mark377

New member
Joined
Jan 10, 2010
Messages
1
Programming Experience
10+
Hi

I am fairly new to VB and I am trying to create an asp VB script which serves up the requested MP3 file like so:

The reason I am doing this is so that it doesn't cache the file in the browser.

http://localhost/nocache.asp?file=1.mp3

however, it is not working as expected. It should allow me to play the file when I go to the url instead it just shows the icon for quicktime.

Any ideas what I am doing wrong here?

VB.NET:
Response.Clear()
Response.AddHeader "Expires", "Mon, 26 Jul 1997 05:00:00 GMT"
Response.AddHeader "Last-Modified", Now & " GMT"
Response.AddHeader "Cache-Control", "no-cache, must-revalidate"
Response.AddHeader "Pragma", "no-cache"
Response.AddHeader "Content-Type", "audio/mpeg"
Response.ContentType = "application/octet-stream"
dim newvar
newvar = Request.QueryString("file")
Response.WriteFile(newvar)
Response.End()
Response.Expires = -1
 
Back
Top