Prev: simple? does host address URL imply the default web server on IIS server hosting multiple websites (multiple host headers)
Next: IIS7 / Basic Authentication
From: IK13 on 5 Apr 2010 18:02
Trying an existing application (which works fine in IIS 7) in IIS 7.5
revealed something that might as well be a bug.
I have a classic asp script (serving Crystal 9 activex viewer actually)
which generates some content, sets a few response headers and sends it down
the wire. It does properly calculate the size of the content and
appropriately sets the content-length header before doing
"Respone.BinaryWrite content". At that moment the server closes the
connection (as reported by Fiddler and WFetch) before anything gets back to
the client (again - according to WFetch and Fiddler). Without setting the
content-length header everything works. It also works if I turn the dynamic
content compression on and configure the content type being sent for
compression. Which makes sense, since the content-length header is ignored in
this case (or perhaps regenerated).
There's a simplified example:
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Filename = Request.QueryString("sFile")
IF (FSO.FileExists(Filename)) Then
Response.Buffer = True
Response.AddHeader "content-disposition", "inline;" 'filename=" &
FSO.GetFileName(Filename) & ""
Content = ReadBinaryFile(Filename)
Response.AddHeader "Content-length", LenB(Content)
Response.Write "<h3><i><font color=red> File " & Filename &_
" does not exist</font></i></h3>"
Set FSO = nothing
Function GetContentType(ByVal Ext)
Select Case UCase(Ext)
GetContentType = "application/pdf"
Case "HTM", "HTML"
GetContentType = "text/html"
GetContentType = "text/xml"
Case "TXT", "CSV"
GetContentType = "text/plain"
GetContentType = "application/octet-stream"
Const adTypeBinary = 1
'Create Stream object
Set BinaryStream = CreateObject("ADODB.Stream")
'Specify stream type - we want To get binary data.
BinaryStream.Type = adTypeBinary
'Open the stream
'Load the file data from disk To stream object
'Open the stream And get binary data from the object
ReadBinaryFile = BinaryStream.Read
Set BinaryStream = Nothing
From: IK13 on 6 Apr 2010 13:21
Looks like it's an ASP bug as (virtually) the same code, rewritten in
ASP.NET/VB.NET runs fine.