Persits Software, Inc. Knowledge Base Articles

SendBinary fails under IIS7 on Vista, Windows 2008 and 7

Problem Description

Under IIS7, the method SendBinary does not appear to work properly. Depending on which browser you use, a file download fails with the error

Internet Explorer cannot display the webpage


This webpage is not available


Connection closed by remote server


The problem has been traced to the Response.AddHeader call

Response.AddHeader( "Content-Length", Size )

that the SendBinary method calls internally. Apparently, under IIS7, the Content-Length header must not be set if Chunked Encoding is used.

To fix the problem, you therefore have two options:

Option 1:

Set both the Enable Buffering and Enable Chunked Encoding options to False under the ASP section in IIS Manager:

Option 2:

Call SendBinary with the 2nd argument set to False. You will then be responsible to provide the values for the Content-Type and Content-Disposition headers. For example:

   Set Upload = Server.CreateObject("Persits.Upload")
   Response.ContentType = "application/octet-stream"
   Response.AddHeader "Content-Disposition", "filename=name.ext"

   Upload.SendBinary Path, False