Beispiel #1
0
    //downloads file
    public void ImageButtonDownload_Click(object sender, ImageClickEventArgs e)
    {
        int id = int.Parse(((System.Web.UI.WebControls.Image)(sender)).AlternateText);

        Byte[] file = AudioFiles.Download(id);
        System.Web.HttpContext context = System.Web.HttpContext.Current;
        context.Response.Clear();
        context.Response.ClearHeaders();
        context.Response.ClearContent();
        context.Response.AppendHeader("content-length", file.Length.ToString());
        context.Response.ContentType = "audio/mpeg";
        context.Response.AppendHeader("content-disposition", "attachment; filename=" + AudioFiles.GetFilenameById(id));
        context.Response.BinaryWrite(file);
        context.ApplicationInstance.CompleteRequest();
    }