ReportViewer for MVC is a simple library that makes it possible to use an ASP.NET ReportViewer control in an ASP.NET MVC application.
It provides a set of HTML Helpers and all of it's dependencies for displaying a report. Local or server, it handles all.
Server controls (like ReportViewer) cannot be used within Razor views. In order to use a control, you would need to add an ASPX view page and all of it's configurations, as well as, work through the code.
This library will setup all of that work for you, and will provide easy access to display your report. Also, it will auto-resize the report on your webpage to get the desired display.
Download & install from NuGet.
PM> Install-Package Datium.ReportViewerForMvc4
After installing, the simplest solution is to setup the report on the controller and render it on the view.
The example below, will configure a report on localhost and auto-resize it. Check more details on the Getting Started page.
Controller:
var reportViewer = new ReportViewer()
{
ProcessingMode = ProcessingMode.Remote,
SizeToReportContent = true,
Width = Unit.Percentage(100),
Height = Unit.Percentage(100),
};
reportViewer.ServerReport.ReportPath = "/ReportFolder/SampleReport";
reportViewer.ServerReport.ReportServerUrl = new Uri("http://localhost/ReportServer/");
ViewBag.DynamicID = Guid.NewGuid().ToString();
ViewBag.ReportViewer = reportViewer;
View:
@Html.ReportViewer(
ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer,
new { scrolling = "no" , DynamicID = ViewBag.DynamicID})
Check the Wiki for the project.