Skip to content

ReportViewer for MVC is a simple library that makes it possible to use an ASP.NET ReportViewer control in an ASP.NET MVC application.

License

Notifications You must be signed in to change notification settings

mganthon/ReportViewerForMvc

 
 

Repository files navigation

ReportViewer for MVC

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.

Why do I need this?

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.

Where can I get it?

Download & install from NuGet.

PM> Install-Package ReportViewerForMvc

How do I use it?

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})

More info

Check the Wiki for the project.

About

ReportViewer for MVC is a simple library that makes it possible to use an ASP.NET ReportViewer control in an ASP.NET MVC application.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 74.7%
  • JavaScript 11.7%
  • HTML 9.8%
  • Classic ASP 2.9%
  • Other 0.9%