I have a asp.net webform application (music website). I want to have a download button. So when users clicked on that. selected music start to download with browser.How can I do that?
here is the code that I tried:
string id_new;
id_new = Session["selectedmusicID"].ToString();
DataTable dt2 = new DataTable();
dt2 = blm.selectMusic("sel_music", Convert.ToInt32(id_new));
string test = dt2.Rows[0][9].ToString();
string test2 = test.Substring(9);
Context.Response.Clear();
Context.Response.Buffer = true;
Context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + test2);
Context.Response.ContentType = "audio/mp3";
Context.Response.TransmitFile(@"~\music\" + test2 );
Context.Response.End();
try this,you may get an idea
Try this:
If you're not using database then try this: