我们有一个动态生成PDF文件并强制下载文件的应用程序。这段代码在Windows Server 2008上没有问题。从我可以看出,似乎IIS强制Content-Length值为749,而应该是83233.我已经尝试在应用程序代码和IIS中设置该值完全忽略它。
以下是服务器的响应标头
Response Headers
-------------------------------------------------------------
Connection: close
Content-Length: 749
Content-Type : application/pdf;charset=UTF-8
Date: Thu, 13 Nov 2014 03:36:03 GMT
Server: Microsoft-IIS/8.5
X-Content-Disposition: attachment;filename=LasVegas.pdf
X-Content-Length :83233
X-Powered-By :ASP.NET
这是代码
<cfcontent reset="true"/>
<cfset variables.temporaryFilePath = "C:\inetpub\wwwroot\LasVegas.pdf">
<cfheader name="Content-Length" value="#getFileInfo(variables.temporaryFilePath).size#"/>
<cfheader name="X-Content-Length" value="#getFileInfo(variables.temporaryFilePath).size#"/>
<cfheader name="X-Content-Disposition" value="attachment;filename=LasVegas.pdf">
<cfcontent type="application/pdf" file="#variables.temporaryFilePath#" deleteFile="no">