ashx byte[]下载

html部分<a href="ashx?参数">

ashx部分

public override void ProcessRequest(HttpContext context)
{
this.UserID = base.BaseUserID;
this.strAttachGuid = context.Request["AttachGuid"];
byte[] bytes = Download(context);

if (bytes != null)
{
context.Response.Buffer = true;
context.Response.Clear();
context.Response.ContentType = "application/download";
context.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(strFileName, System.Text.Encoding.UTF8));
context.Response.BinaryWrite(bytes);
context.Response.Flush();
context.Response.Clear();
context.Response.End();
}
}

原文地址:https://www.cnblogs.com/chengeng/p/12370684.html