ASP.Net Pdf下载遇到的问题 请教一下

怪爸爸的状态 2019-07-03 10:32:02

public static void DownLoadPdf2(string pdfpath, string filename)
{
HttpResponse _Response = HttpContext.Current.Response;
FileInfo fileInfo = new FileInfo(pdfpath);
_Response.Clear();
_Response.ClearHeaders();
_Response.Buffer = false;
_Response.ContentType = "application/octet-stream";
_Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(filename,
System.Text.Encoding.UTF8));
_Response.AppendHeader("Content-Length", fileInfo.Length.ToString());
_Response.TransmitFile(fileInfo.FullName);
_Response.Flush();
_Response.End();
}




下载后 打开文件 出现了

----------------------------656498960640359861281022
Content-Disposition: form-data; name="file"; filename="222.txt"
Content-Type: text/plain

this is a test

----------------------------656498960640359861281022
Content-Disposition: form-data; name="filename"

222.txt
----------------------------656498960640359861281022--



...全文
47 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
怪爸爸的状态 2019-07-03
  • 打赏
  • 举报
回复
我注意到 是我上传以后 文件内容就会改变 我看看上传做了什么操作

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧