Last week I released some code that I created for work to get rid of the ASP.NET WebForms reliance to use a Report Viewer control on your MVC website. Immediately after release, someone commented on my reddit article suggesting that I should see what it would take to enable this for .NET Core. I thought it would be a fun idea to gain some experience with .NET Core so I went for.

The other day, I released the code for the .NET Core portion of the project on the same Github repo and I wanted to share it and see if anyone else wants to try using it.

The way that my code works for viewing the reports is that I’m essentially redrawing the report viewer controls for paging / searching / exporting / printing using Bootstrap (which you don’t have to be tied to). Each button does an ajax call to the controller which has some predefined controller actions to deal with the report viewer features so that you don’t have to reinvent the wheel. The custom controller actions will call into your SSRS ReportExecutionService soap service to get information about the report.

There are sample projects in my codebase that are for the standard ASP.NET MVC Razor and for the .NET Core version of MVC.

Worth Noting

  • This project will work in standard MVC projects as well as .NET Core (there is a library for each).
  • I have only tested this with SSRS Server Reports – since I’m contacting the SSRS ReportExecution asmx file I don’t believe that would work with local rdl files.
  • I’m using the following libraries in my example projects currently
    • JQuery v2.1.1
    • Bootstrap v3.3.7
    • Select2 v4.0.3
    • JQuery Highlight v5 (this is optional and is used for the “Find” feature of the viewer).

How to Set it Up

  1. Install from NuGet packages
    1. Standard .NET Framework –
    2. .NetCore –
    3. Or, download code from GitHub –
  2. Hopefully you already have a project created, if not…set one up.
  3. Determine the correct AlanJuden.MvcReportViewer library to use.
    1. .Net Core based project => AlanJuden.MvcReportViewer.NetCore
    2. ASP.NET MVC based project => AlanJuden.MvcReportViewer
  4. Compile the project you chose from step 3 or pull it into your project.
  5. In your project, you need to setup a ReportController (that’s what I’ve been calling it but you can call it whatever you want).
  6. On your ReportController, you’ll need to inherit from AlanJuden.MvcReportViewer.ReportController.
  7. Add the mvcreportviewer-bootstrap.css to your project.
  8. You’ll now need to setup a couple of properties that are expected by being abstracted on the base ReportController.
    1. This would be a good time to setup the credentials that you need to run as to have access on the report viewer.
  9. Setup a View Page for your Report Viewer, I have been calling mine “ReportViewer.cshtml” (this should live in your /Views/Report/ directory).
    1. You may need to edit the path to some of your script / css files.
  10. Start setting up your own reports on your controller.
  11. You’re all set…give it a try!
  12. Let me know what you think by hitting me up on the comments below, by my contact page, or any of the social sites I have listed on my site.