Here is the page that I'm having trouble with: http://headchemists.com/Song.aspx?id=5
When you click on either "Original Vocal Mix" or "Instrumental Mix" a mp3 file should download. It works correctly in FF / IE, but Safari downloads the mp3 as a .xhtml file. Any help greatly appreciated! Below is my handler code:
private int itemId = -1;
public void ProcessRequest(HttpContext context)
{
context.Response.ClearHeaders();
itemId = int.TryParse(context.Request.QueryString["id"], out itemId) == true ? itemId : -1;
GetPackages get = new GetPackages();
Item item = get.GetItem(itemId);
Package package = get.GetPackage(item.PackageId);
context.Response.AppendHeader("Content-Length", item.BinaryFile.Length.ToString());
context.Response.ContentType = "audio/mpeg";
context.Response.AppendHeader("Content-Disposition", "attachment; filename=\"" + package.Title.Replace(" ", "_") + "_(" + item.Title.Replace(" ", "_") + ")" + ".mp3\"");
context.Response.OutputStream.Write(item.BinaryFile, 0, item.BinaryFile.Length);
context.Response.End();
}