问题:我的网站一个下载功能在其他浏览器上都没有问题!但是在苹果电脑上下载下来的文件会自动加上后缀.html 请教高手解决!
一下是下载文件的代码片段:
WebClient webClient = new WebClient();
HttpContext.Current.Response.BufferOutput = false; HttpContext.Current.Response.Clear(); HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" + ReadConfig.GetCurrentTimeWu() + ".png"); //HttpContext.Current.Response.ContentType = ""; //application/octet-stream"; HttpContext.Current.Response.CacheControl = "Private"; Stream stm = new MemoryStream(webClient.DownloadData(destFileName)); HttpContext.Current.Response.AppendHeader("Content-length", stm.Length.ToString()); BinaryReader br = new BinaryReader(stm); byte[] bytes; for (Int64 x = 0; x < (br.BaseStream.Length / 4096 + 1); x++) { bytes = br.ReadBytes(4096); HttpContext.Current.Response.BinaryWrite(bytes); System.Threading.Thread.Sleep(5); //休息一下,防止耗用带宽太多。 } stm.Close();