Basically, on our website we have a report that lets you export to pdf, excel or just as html.
Things work fine on older browsers (ESR 60), Edge and IE. New versions of Firefox and Chrome will not work with the pdf or excel option.
Html works just fine, but the other two seem to download a temp file as getparms.aspx and then rename it - the two mentioned browsers no longer seem to allow that file to be downloaded (download failed) and renamed in the users temp folder (probably good for security).
From some googling, it seems it could be related to memorystream being used? Most examples I have seen use embedded CR into the aspx page, which doesn't apply to this case.
I have been trying a few different things, but everything has failed so far - I'm not a programmer, just trying to fix what was left behind.
I am including the code for the page that generates the files
Imports CrystalDecisions.Shared Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.Web Partial Class IndexReport_GetParms Inherits System.Web.UI.Page Dim blayer As New BAL #Region " Page_Load " Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim PlantID As Integer = blayer.PlantId Dim rptName As String = Request.QueryString("ReportName") Dim format As String = Request.QueryString("Format") Try Me.CRSource.Report.FileName = "testreport.rpt" Me.CRSource.ReportDocument.SetDatabaseLogon("test", "test1") 'Me.CRSource.ReportDocument.SetParameterValue(0, 0) Me.CRSource.ReportDocument.SetParameterValue(0, PlantID) 'Me.CRSource.ReportDocument.SetParameterValue(2, rptName) Dim ms As IO.MemoryStream Select Case format Case "PDF" ms = Me.CRSource.ReportDocument.ExportToStream(ExportFormatType.PortableDocFormat) Response.Clear() Response.Buffer = True Response.AddHeader("Accept-Header", ms.Length.ToString) Response.ContentType = "application/pdf" Response.OutputStream.Write(ms.ToArray(), 0, Convert.ToInt32(ms.Length)) Response.Flush() Response.Close() ms.Close() Case "EXCEL" ms = Me.CRSource.ReportDocument.ExportToStream(ExportFormatType.Excel) Response.Clear() Response.Buffer = True Response.AddHeader("Accept-Ranges", ms.Length.ToString) Response.ContentType = "application/vnd.ms-excel" Response.OutputStream.Write(ms.ToArray(), 0, Convert.ToInt32(ms.Length)) Response.Flush() Response.Close() ms.Close() Case "HTML" ms = Me.CRSource.ReportDocument.ExportToStream(ExportFormatType.HTML40) Response.Clear() Response.Buffer = True Response.AddHeader("Accept-Ranges", ms.Length.ToString) Response.ContentType = "text/HTML" Response.OutputStream.Write(ms.ToArray(), 0, Convert.ToInt32(ms.Length)) Response.Flush() Response.Close() ms.Close() End Select Catch ex As Exception Throw ex End Try End Sub #End Region End Class
Ideas?
Update - Again, I'm sure related to how it tries to download the .aspx file, this is the error being thrown when trying to export to pdf
"Resource interpreted as Document but transferred with MIME type application/pdf"
I can change application/df to text/HTML and it will display - as gibberish of course.