RDLC 报告(Microsoft reportViewer)在部署到服务器后从客户端计算机访问时未呈现
RDLC reports (Microsoft reportViewer) are not rendering when accessed from client machine after deployed to Server
RDLC 报告 (Microsoft reportViewer) 在部署到服务器后未呈现
当从机器本身内部访问时,我的 rdlc 报告在开发机器(部署后)中正确呈现和工作,它也在部署后在生产服务器中工作(当从机器本身内部访问时)。但是,当我尝试从客户端计算机访问报告时,它并没有呈现 web 应用程序的其他组件是否正常工作。
我得到的错误是:
google chrome : 无法加载 pdf 文档
Internet Exploler: 文件损坏无法修复
我该如何解决这个错误?
我的控制器代码是:
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
我该如何解决这个错误?
由于错误"failed to load pdf file"很难排查,浪费了很多时间在网上搜索,我解决了这个问题
更正
中的初始化
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()
RDLC 报告 (Microsoft reportViewer) 在部署到服务器后未呈现 当从机器本身内部访问时,我的 rdlc 报告在开发机器(部署后)中正确呈现和工作,它也在部署后在生产服务器中工作(当从机器本身内部访问时)。但是,当我尝试从客户端计算机访问报告时,它并没有呈现 web 应用程序的其他组件是否正常工作。
我得到的错误是:
google chrome : 无法加载 pdf 文档
Internet Exploler: 文件损坏无法修复
我该如何解决这个错误?
我的控制器代码是:
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
我该如何解决这个错误?
由于错误"failed to load pdf file"很难排查,浪费了很多时间在网上搜索,我解决了这个问题
更正
中的初始化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()