2009-03-05 5 views
0

Wir haben eine ASP.NET 1.1-Anwendung, die Crystal Reports verwendet, um eine Excel-Tabelle auszuspucken. Der Code funktioniert unter IIS6, aber wenn wir versuchen, ihn nach IIS7 zu migrieren, spuckt er html ohne Inhalt anstelle der Excel-Datei aus.IIS7 Response.WriteBuffer funktioniert nicht

Der MIME-Typ existiert. Unten ist der Code, den wir verwenden. Ich habe diesen Code nicht geschrieben, da ich jetzt hauptsächlich im 3.5 Framework arbeite. Meine Annahme ist, dass ich etwas in der IIS7-Konfiguration nicht den Code vermisse, da es auf IIS6 funktioniert. Der Rest der ASP.NET 1.1-Anwendung funktioniert auf IIS7. Jedoch

„Noch nie zuvor gesehen, ich habe noch nie verwendet sogar den Export vor Option in Kristall zu streamen, wenn:

 Dim cr As ReportClass 
     'EXPORT the report based on the export type passed in. 
     Dim ExpOptions As New ExportOptions 
     Dim ContentType As String 
     Dim strExt As String 
     Trace.Write("DisplayReport reportname=" + ReportName + " SQL=" + SQL + " SQLSub1=" + Convert.ToString(Session("SQLSub1"))) 
     'Get the report filled with the data. 
     If Session("SQLSub1") <> "" Then 
      If Not Session("SubRptName") Is Nothing Then 
       cr = PopulateReport(GetReportObject(ReportName), SQL, Session("SQLSub1"), Session("SubRptName")) 
       Session("SQLSub1") = "" 
       Session("SubRptName") = Nothing 
      Else 
       cr = PopulateReport(GetReportObject(ReportName), SQL, Session("SQLSub1")) 
       Session("SQLSub1") = "" 
      End If 
     Else 
      cr = PopulateReport(GetReportObject(ReportName), SQL) 
     End If 

     If DisplayType = ReportType.Excel Then 
      If ReportName.ToUpper = "ACTION" Or ReportName.ToUpper = "INVENTORY_EXCEL" _ 
       Or ReportName.ToUpper = "UNDERPERFORM" Or ReportName.ToUpper = "EMPLOYEE_EXCEL" Then 
       Dim excelFormatOpts As New ExcelFormatOptions 
       ' Set the excel format options. 
       excelFormatOpts.ExcelTabHasColumnHeadings = True 
       excelFormatOpts.ExcelUseConstantColumnWidth = False 
       ExpOptions.FormatOptions = excelFormatOpts 
      Else 
       ExpOptions.FormatOptions = New ExcelFormatOptions 
      End If 
      ExpOptions.ExportFormatType = ExportFormatType.Excel 
      ContentType = "application/vnd.ms-excel" 
      strExt = ".xls" 
     ElseIf DisplayType = ReportType.PDF Then 
      ExpOptions.ExportFormatType = ExportFormatType.PortableDocFormat 
      ExpOptions.FormatOptions = New PdfRtfWordFormatOptions 
      ContentType = "application/pdf" 
      strExt = ".pdf" 
     End If 

     'Stream the report to the screen 
     Dim req As New ExportRequestContext 
     req.ExportInfo = ExpOptions 

     Dim s As Stream 
     Try 
      s = cr.FormatEngine.ExportToStream(req) 
     Catch ex As Exception 
      Trace.Warn("DisplayReport cr.FormatEngine.ExportToStream(req) failed: " + ex.Message) 
      Dim x As String = String.Empty 
     End Try 


     Response.Clear() 
     'Response.ClearHeaders() 
     'Response.ClearContent() 
     Response.Buffer = True 
     Response.ContentType = ContentType 
     Response.AddHeader("Content-Type", ContentType) 


     Dim buffer(s.Length) As Byte 
     s.Read(buffer, 0, Int(s.Length)) 
     Response.BinaryWrite(buffer) 

     Dim strContentDisposition As String = "inline;filename=" & ReportName.ToString.ToLower & strExt.ToString 
     Trace.Write("DisplayReport strContentDisposition=" + strContentDisposition) 
     Response.AddHeader("Content-Disposition", strContentDisposition) 
     Response.Cache.SetMaxAge(New TimeSpan(0, 0, 10)) 
     Response.End() 

Antwort

0

einige Devs hier bei der Arbeit gestellt, das ist, was ich so weit gekommen. Ich sollte raten, ich würde Serverberechtigungen als möglichen Fehler betrachten. Ich habe Situationen gesehen, in denen der Benutzer spezielle Rechte haben muss, um auf Streams zuzugreifen. "