尝试从远程服务器下载 zip 文件时,我们从 BITS 作业中收到此错误(我们为该服务器上的 zip 文件实现了 HTTP 处理程序):
错误代码:0x80200013 - 服务器不支持必要的 HTTP 协议。后台智能传输服务 (BITS) 要求服务器支持 Range 协议标头。
错误上下文:0x00000005 - 处理远程文件时发生错误。
我的理解是该错误表明我们应该添加 Content-Range 标头。我添加了标题,现在代码如下所示:
context.Response.ContentType = "application/x-zip-compressed";
context.Response.AppendHeader("Content-Disposition", string.Format("inline; fileName={0}", downloadFileName));
context.Response.AppendHeader("Content-Range", "bytes " + start + "-" + end + "/" + size);
context.Response.AppendHeader("Content-Length", fs.Length.ToString());
fs.CopyTo(context.Response.OutputStream);
context.Response.Flush();
context.Response.Close();
,但我一直收到同样的错误。
我还尝试了以下行:
context.Response.AppendHeader("Accept-Ranges", "bytes");
但最终出现了另一个错误:“与服务器的连接异常终止”。下载链接在浏览器中运行良好。
我将不胜感激任何想法,谢谢!