Hi,
I am returning the ReportViewer object from MVC Controller to aspx view.
Controller:
[HttpPost]
public ActionResult PortedDataReport(PortedDataReport portedDataReport)
{
ReportViewer mainReportViewer = new ReportViewer();
mainReportViewer.ServerReport.ReportServerUrl =
new Uri("http://ServerName:8080/ReportServer");
mainReportViewer.ServerReport.ReportPath = "/SSRS_Reports/PortingStatusReportFinal";
mainReportViewer.ProcessingMode = ProcessingMode.Remote;
mainReportViewer.ShowRefreshButton = false;
mainReportViewer.ShowWaitControlCancelLink = false;
mainReportViewer.ShowBackButton = false;
mainReportViewer.ShowCredentialPrompts = false;
var parametersCollection = new List<ReportParameter>();
parametersCollection.Add(new ReportParameter("FilePortingId",portedDataReport.FileId.ToString(),false));
parametersCollection.Add(new ReportParameter("PortedDateFrom", portedDataReport.PortedDataFrom.ToString(), false));
parametersCollection.Add(new ReportParameter("ClientId", portedDataReport.ClintId.ToString(), false));
parametersCollection.Add(new ReportParameter("PortedDateTo", portedDataReport.PortedDataTo.ToString(), false));
mainReportViewer.ServerReport.SetParameters(parametersCollection);
mainReportViewer.ServerReport.Refresh();
portedDataReport.ReportViewer = mainReportViewer;
return View(portedDataReport);
}
ASPX View:
<% if (Model !=null) {
if(Model.ReportViewer != null)
{
ReportViewer1.Visible = true;
ReportViewer1 = Model.ReportViewer;
ReportViewer1.Width = Unit.Pixel(1286);
ReportViewer1.Height = Unit.Pixel(402);
ReportViewer1.ServerReport.Refresh();
}%>
<% }
else
{
ReportViewer1.Visible = false;
}
%>
But, When i run the report i am getting the following error.This is working fine when i directly bind the ReportServer URL and Path directly to the Reportviewer in aspx.
Error:
The attempt to connect to the report server failed. Check your connection information and that the report server is a compatible version.
The request failed with HTTP status 404: Not Found.
Please suggest me if there is any better returning report from MVC Controller to aspx View.
Thanks,
Prasad.