首页 > 编程 > JavaScript > 正文

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

2019-11-20 22:56:06
字体:
来源:转载
供稿:网友
复制代码 代码如下:

    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";  
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表