IIS 8.5 forces invalid Content-Length header

We have an application that dynamically generates PDF files and forces the download of the file. This code worked without issue on Windows Server 2008. From what I can tell, it seems that IIS forces the Content-Length to be 749 and it should be 83233. I tried to set this value in my application code and IIS ignores it completely.

  • Microsoft URL Rewrite is installed, but there are no entries for this site.
  • I disabled compression of static and dynamic content
  • Through my application code, I am trying to set the Content-Length header as well as the X-Content-Length header to the same value. This is how I am sure the value is being overwritten by IIS
  • When I click the same URL via the ColdFusion Embedded Web Server, the download works without issue. This is why I know it is a problem with IIS or the connector between IIS and ColdFusion.

Here are the response headers from the server

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

      

Here is the code

<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">

      

+3


source to share





All Articles