string contentType = MimeMapping.GetMimeMapping(name);var isIOS = false; if (Request.UserAgent != null && (Request.UserAgent.Contains("iPhone") || Request.UserAgent.Contains("iPad"))) { isIOS = true; } var isWeChat = false; ///Mozilla/5.0 (iPhone; CPU iPhone OS 14_5 like Mac OS X) ///AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.12(0x18000c28) NetType/WIFI Language/zh_CN /// ///Mozilla/5.0 (iPhone; CPU iPhone OS 14_5 like Mac OS X) ///AppleWebKit /605.1.15 (KHTML, like Gecko) Mobile/15E148 wxwork/3.1.15 MicroMessenger/7.0.1 Language/zh ColorScheme/Light if (Request.UserAgent != null&&(Request.UserAgent.Contains("MicroMessenger")) && (Request.UserAgent.Contains("wxwork"))) { isWeChat = false; } else if (Request.UserAgent != null && (Request.UserAgent.Contains("MicroMessenger"))) { isWeChat = true; } WebClient my = new WebClient(); mybyte = my.DownloadData(pingUrl); if (isIOS) { if (isWeChat) { Response.AppendHeader("Content-Disposition", "filename=" + name); return File(mybyte, contentType, Url.Encode(name)); } else { Response.AppendHeader("Content-Disposition", "attachment;filename=" + name); return File(mybyte, contentType, name); } } return File(mybyte, contentType, Url.Encode(name));