public class DownloadTest : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string f1 = context.Request["f1"];//文件流
//指定为下载操作
context.Response.ContentType = "application/octet-stream";
//附加头信息,表示保存文件时的文件名
context.Response.AddHeader("Content-Disposition", "attachment; filename=\""+f1+"\";");
//输出文件
context.Response.WriteFile(context.Request.MapPath(f1));
}
public bool IsReusable
{
get
{
return false;
}
}
}
时间: 2024-11-12 22:00:44