public ActionResult Download(int id) { UpDownProcess.UpDownProcess Download = new UpDownProcess.UpDownProcess(); Hashtable H = Download.Download(ConnectString, id); if (H != null) { TempData["AlertMessage"] = "開始下載"; } else { TempData["AlertMessage"] = "下載失敗"; } Response.Clear(); Response.Buffer = true; Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = H["contentType"].ToString(); Response.AppendHeader("Content-Disposition", "attachment; filename=" + H["fileName"].ToString()); Response.BinaryWrite((byte[])H["bytes"]); Response.Flush(); Response.End(); return(RedirectToAction("Index")); }
protected void DownloadFile_Click(object sender, EventArgs e) { //string GUID = (sender as LinkButton).CommandArgument; UpDownProcess.UpDownProcess Download = new UpDownProcess.UpDownProcess(); Hashtable H = Download.Download(ConnectString, Convert.ToInt16(txtFileId.Text)); Response.Clear(); Response.Buffer = true; Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = H["contentType"].ToString(); Response.AppendHeader("Content-Disposition", "attachment; filename=" + H["fileName"].ToString()); Response.BinaryWrite((byte[])H["bytes"]); Response.Flush(); Response.End(); }