asp.net下载文件中文名乱码

发布时间:2018-10-17编辑:admin阅读(1298)

FileInfo fn = new FileInfo(Server.MapPath("/download") + "\\测试.zip");
Context.Response.Clear();
Context.Response.AddHeader("Content-Disposition", "attachment;filename=" + Context.Server.UrlEncode("测试.zip"));//添加头信息。为“文件下载/另存为”指定默认文件名称,对中文文件名进行URL编码解决中文乱码
Context.Response.AddHeader("Content-Length", fn.Length.ToString());//添加头文件,指定文件的大小,让浏览器显示文件下载的速度
Context.Response.TransmitFile("/download/测试.zip"");//微软为Response对象提供了一个新的方法TransmitFile来解决使用Response.BinaryWrite 下载超过400mb的文件时导致Aspnet_wp.exe进程回收而无法成功下载的问题。
Context.Response.End();


  关键字:asp.net下载文件中文名乱码


鼓掌

0

正能量

0

0

呵呵

0


评论区