I\'m working on an MVC4 application that needs to render a remote report from SSRS using the ReportViewer. With help from this forum, I\'ve managed to get the page to render
In the end, I ended up having to ditch both my original answer and the callbacks criteria due to the unacceptable security risks. In my case, I wrote controller code rendering the report as HTML to a byte array and from there to a FileContentResult that MVC was kind enough to render as a static HTML page. Exporting as PDF, Excel, or any other options will eventually be implemented in a similar method by changing the Render parameter from HTML4.0 to whatever is appropriate (PDF,XLS) and the MIME type. This approach works with SQL Server 2008R2 and beyond. I haven't tried it with previous versions of SQL Server.
[OutputCache(Duration = 120, VaryByParam = "id")]
public ActionResult ExportHTML(int id)
{
// we need to add code to check the user's access to the preliminary report.
// Also need to consolidate code between ExportHTML and ExportPDF.
var userid = ;
var password = ;
var domain = ;
IReportServerCredentials irsc = new myApp.Models.CustomReportCredentials(userid,
password, domain);
var parametersCollection = new List();
parametersCollection.Add(new ReportParameter("Snapshot", id.ToString(), false));
ReportViewer rv = new Microsoft.Reporting.WebForms.ReportViewer();
rv.ProcessingMode = ProcessingMode.Remote;
rv.ServerReport.ReportServerCredentials = irsc;
rv.ServerReport.ReportPath = ;
rv.ServerReport.ReportServerUrl = new Uri("http://localhost/ReportServer");
rv.ServerReport.SetParameters(parametersCollection);
rv.ServerReport.Refresh();
byte[] streamBytes = null;
string mimeType = "";
string encoding = "";
string filenameExtension = "";
string[] streamids = null;
Warning[] warnings = null;
streamBytes = rv.ServerReport.Render("HTML4.0", null, out mimeType, out encoding,
out filenameExtension, out stream ids,
out warnings);
var HTMLReport = File(streamBytes, "text/html");
return HTMLReport;
}