这个不是代码的问题,在360浏览器上就能正常下载。下面是我下载使用的代码
#region 下载文件
//DESPath是物理路径
FileInfo fileInfo = new FileInfo(DESPath);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment;filename=config.sida");
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
Response.AddHeader("Content-Transfer-Encoding", "binary");
Response.ContentType = "application/octet-stream";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
Response.WriteFile(fileInfo.FullName);
Response.Flush();
Response.End();
#endregion
解决方法:
在网上找到这个帖子
https://zhidao.baidu.com/question/508228124.html
里面有提到可能是应为使用了迅雷下载了,这和我的情况一致。设置迅雷不检测浏览器的下载,使用网页下载,我的问题就解决了。当然最好在测试前清理一下浏览器的缓存。