G
Goldenrate
Hi Everyone,
I'm trying to force My application to download MP3 file instead of playing
it in browser.
I used this asp cod to create download image
/******************//
<asp:ImageButton ID="ibDownload" runat="server" style="border:0;"
ImageUrl="~/DesktopModules/ASPvia_AudioDownload/images/Download.jpg"
onclick="ibDownload_Click" />
</div>
/*********************/
When clicked it calls
/***********************/
protected void ibDownload_Click(object sender, ImageClickEventArgs e)
{
string f =
String.Concat("Portals\\0\\",GetUserIDForProductOwner(),"\\",GetMediaFileName());
string filePath = Server.MapPath(f);
Response.Clear();
Response.AddHeader("content-disposition", "attachment;
filename=" + GetMediaFileName());
Response.ContentType = "application/audio/mpeg";
Response.WriteFile(filePath);
Response.End();
}
/*******************************/
GetMediaFileName() - retrieve the file name from the database.
f - stores the virtual directory of the file.
I've checked the code time and time again and found nothing wrong.
Does anybody know what am I doing wrong?
Thanks,
I'm trying to force My application to download MP3 file instead of playing
it in browser.
I used this asp cod to create download image
/******************//
<asp:ImageButton ID="ibDownload" runat="server" style="border:0;"
ImageUrl="~/DesktopModules/ASPvia_AudioDownload/images/Download.jpg"
onclick="ibDownload_Click" />
</div>
/*********************/
When clicked it calls
/***********************/
protected void ibDownload_Click(object sender, ImageClickEventArgs e)
{
string f =
String.Concat("Portals\\0\\",GetUserIDForProductOwner(),"\\",GetMediaFileName());
string filePath = Server.MapPath(f);
Response.Clear();
Response.AddHeader("content-disposition", "attachment;
filename=" + GetMediaFileName());
Response.ContentType = "application/audio/mpeg";
Response.WriteFile(filePath);
Response.End();
}
/*******************************/
GetMediaFileName() - retrieve the file name from the database.
f - stores the virtual directory of the file.
I've checked the code time and time again and found nothing wrong.
Does anybody know what am I doing wrong?
Thanks,