B
Brad
I have a .net 2.0 web application project that creates a pdf file, saves the pdf to disk (crystal reports does this
part), and
then my code reads the pdf file and writes it to the httpresponse The web app works great on win2003 and xp and the end
result is a pdf file is displayed in the browser. When I run the same code on Vista, the browser displays the message
"Internet Explorer cannot display the web page". If I open the same pdf file directly from the browser it displays
correctly. If I trace the code no exceptions are thrown. I am running this as an IIS application. If I switch to
cassini it
works correctly.
What might cause this problem in IIS7?
Here is an example of the code (and the page source has no html content, and agin work find under IIS running on
win2003 and xp)
Dim outputFile As String = Path.Combine(folderPath, Current.Session.SessionID & ".pdf")
Dim contentType As String
contentType = "application/pdf"
With Current.Response
If System.IO.File.Exists(outputFile) = True Then
.ClearContent()
.ClearHeaders()
.ContentType = contentType
Dim fs As FileStream = New FileStream(outputFile, FileMode.Open)
Try
Dim bufferSize As Integer = CType(fs.Length, Integer)
Dim bt(bufferSize) As Byte
fs.Read(bt, 0, bufferSize)
.BinaryWrite(bt)
Catch ex As Exception
System.Web.HttpContext.Current.Trace.Warn(ex.Message)
Throw ex
Finally
fs.Close()
End Try
'########################################
.Flush()
.Close()
Else
System.Web.HttpContext.Current.Trace.Warn("Report file not found: " & outputFile)
Throw New Exception("PostExportToClient: File not found " & outputFile)
End If
End With
part), and
then my code reads the pdf file and writes it to the httpresponse The web app works great on win2003 and xp and the end
result is a pdf file is displayed in the browser. When I run the same code on Vista, the browser displays the message
"Internet Explorer cannot display the web page". If I open the same pdf file directly from the browser it displays
correctly. If I trace the code no exceptions are thrown. I am running this as an IIS application. If I switch to
cassini it
works correctly.
What might cause this problem in IIS7?
Here is an example of the code (and the page source has no html content, and agin work find under IIS running on
win2003 and xp)
Dim outputFile As String = Path.Combine(folderPath, Current.Session.SessionID & ".pdf")
Dim contentType As String
contentType = "application/pdf"
With Current.Response
If System.IO.File.Exists(outputFile) = True Then
.ClearContent()
.ClearHeaders()
.ContentType = contentType
Dim fs As FileStream = New FileStream(outputFile, FileMode.Open)
Try
Dim bufferSize As Integer = CType(fs.Length, Integer)
Dim bt(bufferSize) As Byte
fs.Read(bt, 0, bufferSize)
.BinaryWrite(bt)
Catch ex As Exception
System.Web.HttpContext.Current.Trace.Warn(ex.Message)
Throw ex
Finally
fs.Close()
End Try
'########################################
.Flush()
.Close()
Else
System.Web.HttpContext.Current.Trace.Warn("Report file not found: " & outputFile)
Throw New Exception("PostExportToClient: File not found " & outputFile)
End If
End With