VS2010 And SSRS Report Viewer Hanging

The other day I needed to integrated Reporting Services reports with a web application.  I knew I wanted to use the ReportViewer control, but I ran into a few issues of which I’ll state here.  Briefly, one issue is that the web application was already an ASP.NET MVC application, so I wanted to see if I could get the control to work with a view.  I tried to wrap the control in a <form runat=server>, because it needs viewstate, etc  Some ASP.NET controls will work just fine in MVC, no biggy, but this one is a no go.  So I was left with using webforms, not the ideal, but that’s what I had to work with.  So the big issue I ran into was that the ReportViewer control would hang and never load a report.  It turns out that they made some fixes to the async rendering behavior.  To avoid having the report hang you need to set report properties on the initial page post only, as shown below.

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
rptViewer.ServerReport.ReportPath = "/MyReportFolder/My Report";
rptViewer.ServerReport.ReportServerUrl = new Uri("http://SomeRptServerName/ReportServer/");
}
}

No comments: