ashx byte[]下载

Posted chengeng

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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();
}
}

以上是关于ashx byte[]下载的主要内容,如果未能解决你的问题,请参考以下文章

如何打开ashx文件

如何通过unity实现ashx的依赖注入

response下载csv文件内容乱码问题

文件下载

创建一个 CSV 并返回为 byte[] 以在 Spring Controller 中下载

电脑上怎么刷机vivo安卓手机