RDLC报表(Microsoft reportViewer)部署到服务器后未呈现 当从机器本身访问时,我的rdlc报告可以正确地渲染并在开发机器中(在部署后)工作,而在部署(当从机器本身内部进行访问)时,它也可以在生产服务器中工作。但是,当我尝试从客户端计算机访问报告时,它不能使Web应用程序的其他组件正常工作。
我得到的错误是:
google chrome:无法加载pdf文档
Internet Explorer:文件已损坏,无法修复
如何解决此错误?
我的控制器代码是:
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
我该如何解决此错误?
答案 0 :(得分:0)
因为错误“无法加载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()