IIS7 – 在ASP中指定内容长度标头会导致“连接重置”错误

我正在将一系列网站从现有的IIS5服务器迁移到全新的IIS7 Web服务器.其中一个页面数据库中的blob中提取数据文件并将其提供给最终用户
Response.ContentType = rs("contentType")
response.addheader "Content-disposition","attachment;filename=" & Trim(rs("docName"))&rs("suffix")' let the browser kNow the file name
response.addheader "Content-Length",cstr(rs("docsize"))' let the browser kNow the file size

在新的IIS7安装中对此进行测试,我在Internet Explorer和Firefox中都出现“连接重置”错误.如果删除Content-Length标头,则文档会正确提供(但用户将无法获得有用的进度条).

关于如何纠正这个问题的任何想法;无论是服务器配置选项还是通过代码

编辑1:多做了一些试验和错误.如果“启用缓冲”和“启用分块编码”均为假,则请求将成功.如果其中任何一个启用,则会发生错误.

编辑2:更多试验和错误测试;事实证明,文本文件可以正常使用脚本;只有二​​进制文件(图像,pdf等)才会失败.否则仍然完全无能为力.

解决方法

正如其他地方已经提到的那样: http://en.wikipedia.org/wiki/Chunked_transfer_encoding

它使用transfer-encoding HTTP响应头代替Content-Length头,否则协议将需要该头.由于未使用Content-Length标头,因此服务器在开始向客户端(通常是Web浏览器)发送响应之前不需要知道内容的长度.在知道该内容的总大小之前,Web服务器可以开始使用动态生成内容传输响应.

在IIS7中,认情况下启用此选项:
http://technet.microsoft.com/en-us/library/cc730855(v=ws.10).aspx

To enable HTTP 1.1 chunked transfer encoding for the World Wide Web
publishing service,use the following Syntax:

appcmd set config /section:asp /enableChunkedEncoding:True|False

True enables HTTP 1.1 chunked transfer encoding whereas False disables
HTTP 1.1 chunked transfer encoding. The default value is True.

我们有同样的问题,我们的解决方案:删除AddHeader“Content-Length”

相关文章

这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识...
Some samples are below for ASP.Net web form controls:(fr...
问题描述: 对于未定义为 System.String 的列,唯一有效的值...
最近用到了CalendarExtender,结果不知道为什么发生了错位,...
ASP.NET 2.0 page lifecyle ASP.NET 2.0 event sequence cha...