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
I'm still hoping for a better answer but in the meantime, my solution appears to satisfy the criteria. It makes use of the Kendo Web Window (so I suppose you could theoretically write your own using jQuery). I haven't modified it yet to pass parameters, but it's a start. I also haven't secured the redirect action, so it's currently possible for a user to view the source, grab the URL from the jQuery load, go to that address and get the underlying report URL from there. I'm going to look into marking it as a ChildActionOnly or some other means of insuring that the action is only available to my window. I also found that I can render the report to HTML4.0, stuff that in a FileResult and load the content that way as well - but then the report is static HTML.
View:
@(Html.Kendo().Grid(Model)
.Name("IndexGrid")
.Columns(col =>
{
col.Bound(c => c.SchoolYear);
col.Bound(c => c.SubmissionTypeDesc);
col.Bound(c => c.EntityDesc);
col.Bound(c => c.SubmissionDate);
col.Bound(c => c.UserName);
col.Bound(c => c.Certified);
col.Command(c =>
{
c.Custom("Edit")
.Text("View")
.Action("Edit", "Draft");
c.Custom("Preview")
.Click("windowOpen");
c.Custom("Certify")
.Action("Certify", "Draft");
c.Custom("Download")
.Action("DumpExcel", "Draft");
}
).Title("Actions")
.HtmlAttributes(new { style = "width:200px;" });
})
.DataSource(ds => ds.Server()
.Model(model => model.Id(pk => pk.snapshot_id))
)
.Sortable(sort => sort.Enabled(true).SortMode(GridSortMode.MultipleColumn).AllowUnsort(true))
.Reorderable(reorder => reorder.Columns(true))
.Groupable(group => group.Enabled(true))
)
@(Html.Kendo().Window()
.Name("window") //The name of the window is mandatory. It specifies the "id" attribute of the widget.
.Title("Preliminary Report") //set the title of the window
.LoadContentFrom("Redir", "Reports") //define the Action and Controller name
.Visible(false)
.Iframe(true)
.Resizable()
.Width(750)
.Height(500)
.Scrollable(false)
.Draggable()
.Actions(a =>
{
a.Refresh();
a.Minimize();
a.Maximize();
a.Close();
})
)
ReportController snippet:
public ActionResult Redir()
{
return RedirectPermanent("../ASPReports/ReportForm.aspx");
}
ReportForm.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="~/ASPReports/ReportForm.aspx.cs" Inherits="MyApp.Reports.ReportForm"%>
<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
ReportForm.aspx.cs (code-behind):
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// credentials - could pull from config
var userid = "";
var password = "";
var domain = "";
IReportServerCredentials irsc = new CustomReportCredentials(userid, password, domain);
mainReportViewer.ServerReport.ReportServerCredentials = irsc;
//mainReportViewer.ServerReport.ReportServerUrl =
// new Uri(ConfigurationManager.AppSettings["ReportServerUrl"]);
mainReportViewer.ServerReport.ReportServerUrl =
new Uri("http://localhost/ReportServer");
mainReportViewer.ServerReport.ReportPath = "Path";
mainReportViewer.ProcessingMode = ProcessingMode.Remote;
mainReportViewer.ShowParameterPrompts = false;
mainReportViewer.ShowRefreshButton = false;
mainReportViewer.ShowWaitControlCancelLink = false;
mainReportViewer.ShowBackButton = false;
mainReportViewer.ShowCredentialPrompts = false;
var parametersCollection = new List();
//parametersCollection.Add(new ReportParameter("Snapshot", "##", false));
mainReportViewer.ServerReport.SetParameters(parametersCollection);
mainReportViewer.ServerReport.Refresh();
}
}