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: Dim FSO Dim Filename Dim Content Set FSO = Server.CreateObject("Scripting.FileSystemObject") Filename = Request.QueryString("sFile") IF (FSO.FileExists(Filename)) Then Response.Clear Response.Buffer = True Response.AddHeader "content-type", GetContentType(FSO.GetExtensionName(Filename)) Response.AddHeader "content-disposition", "inline;" 'filename=" & FSO.GetFileName(Filename) & "" Content = ReadBinaryFile(Filename) Response.AddHeader "Content-length", LenB(Content) Response.BinaryWrite Content Else Response.Write "<h3><i><font color=red> File " & Filename &_ " does not exist</font></i></h3>" End If Set FSO = nothing Function GetContentType(ByVal Ext) Select Case UCase(Ext) Case "PDF" GetContentType = "application/pdf" Case "HTM", "HTML" GetContentType = "text/html" Case "XML" GetContentType = "text/xml" Case "TXT", "CSV" GetContentType = "text/plain" Case Else GetContentType = "application/octet-stream" End Select End Function Function ReadBinaryFile(FileName) Const adTypeBinary = 1 'Create Stream object Dim BinaryStream Set BinaryStream = CreateObject("ADODB.Stream") 'Specify stream type - we want To get binary data. BinaryStream.Type = adTypeBinary 'Open the stream BinaryStream.Open 'Load the file data from disk To stream object BinaryStream.LoadFromFile FileName 'Open the stream And get binary data from the object ReadBinaryFile = BinaryStream.Read BinaryStream.Close Set BinaryStream = Nothing End Function
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. l |