通过asp.net下载附件的步骤

通过asp.net下载附件的步骤

protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["ID"] == null)
return;

string AttaID = Request.QueryString["ID"].ToString();
string FileName = Request.QueryString["FileName"].ToString();

byte[] filebyte = new WebClass.Errands().Customer_Atta_Get(AttaID);
Response.Clear();
Response.AppendHeader("Content-Disposition", "attachment;filename=" +Server.UrlEncode(FileName));
Response.AppendHeader("Content-Length", filebyte.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.OutputStream.Write(filebyte, 0, filebyte.Length);
Response.End();
}