代码之家  ›  专栏  ›  技术社区  ›  The Scientific Method

RDLC报表(Microsoft reportViewer)在部署到服务器后从客户端计算机访问时不会呈现

  •  0
  • The Scientific Method  · 技术社区  · 6 年前

    RDLC报表(Microsoft reportViewer)部署到服务器后未呈现 当从机器内部访问时,我的rdlc报告在开发机器(部署后)中正确呈现和工作,部署后(从机器内部访问时)它也在生产服务器中工作。但是,当我试图从客户机访问报表时,它并没有呈现web应用程序的其他组件是否正常工作。

    我得到的错误是:

    谷歌浏览器: 未能加载pdf文档

    互联网爆炸者: 文件已损坏,无法修复

    如何修复此错误?

    我的控制器代码是:

            Function GenerateReportS(value As String, lcvalue As String) As ActionResult
            Dim assetlist As List(Of usp_standardreportquery_Result)
            If value IsNot Nothing Or lcvalue IsNot Nothing Then
                assetlist = db.usp_standardreportquery.Where(Function(r) If(value IsNot Nothing, r.AssignLocation = value, True) And
                                                                 If(lcvalue IsNot Nothing, r.LocationCategory = lcvalue, True)).ToList
            Else
                assetlist = db.usp_standardreportquery.ToList
            End If
    
            Dim warnings As Warning()
            Dim mimeType As String
            Dim streamids As String()
            Dim encoding As String
            Dim filenameExtension As String
    
            Dim viewer = New ReportViewer()
            viewer.LocalReport.ReportPath = "Views\Reports\StandardReport.rdlc"
    
            Dim dataset As Microsoft.Reporting.WebForms.ReportDataSource = New Microsoft.Reporting.WebForms.ReportDataSource("standardreportds", assetlist)
    
            viewer.LocalReport.DataSources.Add(dataset)
            Dim params(2) As ReportParameter
            params(0) = New ReportParameter("SearchBy", "Location", False)
            params(1) = New ReportParameter("value", value, False)
            params(2) = New ReportParameter("Category", lcvalue, False)
    
            viewer.LocalReport.SetParameters(params)
    
            dataset.Value = assetlist
            viewer.LocalReport.Refresh()
    
            Dim bytes = viewer.LocalReport.Render("PDF", Nothing, mimeType, encoding, filenameExtension, streamids,
    warnings)
    
            Return New FileContentResult(bytes, mimeType)
    
            'Return File(bytes, mimeType, "_PackingSlip.pdf")
        End Function
    

    如何修复此错误?

    1 回复  |  直到 6 年前
        1
  •  0
  •   The Scientific Method    6 年前

    由于“未能加载pdf文件”的错误很难解决,在浪费大量时间和搜索网页之后,我作为同事解决了这个问题

    正在更正中的初始化

    Dim warnings As Warning()
    Dim streamids As String()
    Dim mimeType As String = "application/pdf"
    Dim encoding As String = String.Empty
    Dim filenameExtension As String = String.Empty
    

    最后在 Dim bytes =

    Response.Buffer = True
    Response.Clear()
    Response.ContentType = mimeType
    Response.BinaryWrite(bytes)
    Response.Flush()