网络编程
位置:首页>> 网络编程>> JavaScript>> 下载文件个别浏览器文件名乱码解决办法

下载文件个别浏览器文件名乱码解决办法

  发布时间:2024-04-17 10:05:04 

标签:下载,文件名乱码

    if (context.Request.UserAgent.ToLower().IndexOf("msie", System.StringComparison.Ordinal) > -1)//IE浏览器
 {
     context.Response.AddHeader("content-disposition", "filename=" + HttpUtility.UrlEncode(fileName));
 }
 if (context.Request.UserAgent.ToLower().IndexOf("firefox", System.StringComparison.Ordinal) > -1)//firefox浏览器
 {
     context.Response.AddHeader("content-disposition", "attachment;filename=\"" + fileName + "\"");
 }
 else//其他浏览器
 {
     context.Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
 }
 context.Response.ContentType = "application/x-xls";  
0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com