• response 下载文件火狐浏览器文件名乱码问题


     string path = Server.MapPath(Url.Content("~/") + "UploadFiles/Template/");
                
                FileStream fs = new FileStream(path + file, FileMode.Open);
                byte[] bytes = new byte[(int)fs.Length];
                fs.Read(bytes, 0, bytes.Length);
                fs.Close();
                Response.ContentType = "application/octet-stream";

                if (Request.UserAgent.ToLower().IndexOf("firefox") > -1) //火狐浏览器
                {
                    Response.AddHeader("Content-Disposition", "attachment;filename="" + file + """);
                }
                else //其他浏览器
                {
                    Response.AddHeader("Content-Disposition", "attachment;  filename=" + HttpUtility.UrlEncode(file, System.Text.Encoding.UTF8));
                }
                
                Response.BinaryWrite(bytes);
                Response.Flush();
                Response.End();

  • 相关阅读:
    apache多端口映射
    mark
    一些注册表值
    jsp URL中文处理的几种方式
    【引用】雨林木风Ghost XP SP3系统
    CentOS常用命令
    查看ie8临时文件夹
    卡塔兰数
    大数问题
    不会做的题目
  • 原文地址:https://www.cnblogs.com/workstation-nigoudongma/p/9883577.html
Copyright © 2020-2023  润新知