Chat Icon
Webinar A Deep Dive into Report Parts for Accelerated and Reusable Reporting - Thursday, February 29, 10:00 A.M. ET SIGN UP NOW
Created with Sketch.
How to Add the Report Viewer to an ASP.NET MVC Application
Add the Report Viewer to an ASP.NET MVC Application | Reporting Tools

How to Add the Report Viewer to an ASP.NET MVC Application

This blog explains how you can create an ASP.NET MVC reporting web application to display an SSRS RDL report using the Bold Reports ASP.NET MVC Report Viewer.

The Report Viewer is a reporting control that empowers web and desktop applications with the ability to view SSRS RDL and RDLC reports and export them.


  • Microsoft Visual Studio 2010 or later.
  • .NET Framework 4.5 or higher.


  1. Create an ASP.NET MVC app.
  1. Open Visual Studio 2022 and click Create a New Project.
  2. Choose ASP.NET Web Application (.NET Framework) and then click Next.
  3. Provide a project name and then click Create.
  4. Select the MVC project template, select the Web API checkbox, and click Create. It creates a default ASP.NET MVC application.

    Create an ASP.NET MVC application | Reporting Tools
    Create an ASP.NET MVC application
  1. Install the NuGet packages.
  1. In the solution explorer tab, right-click the project or solution, and choose Manage NuGet Packages from the context menu.
  2. In the browse tab, search for the BoldReports.Web, BoldReports.Mvc, and BoldReports.JavaScript packages and install them in your MVC application. The purpose of each package is as follows.
Package Purpose
BoldReports.Web Contains interfaces and methods to create a Web API service to process the reports.
BoldReports.Mvc5 Contains HTML tag helpers to create client-side Report Viewer control.
BoldReports.JavaScript Contains reporting component scripts and style sheets.

Note: The dependent packages will be installed automatically on installing the BoldReports.Web package.

  1. Register the namespace.

Open the web.config file from the Views folder and register the BoldReports.Mvc namespace under the namespace tag as shown in the following code sample.

<pages pageBaseType="System.Web.Mvc.WebViewPage">
<add namespace="BoldReports.Mvc"/>
  1. Disable Unobtrusive mode

Open the web.config file from the root directory and set the UnobtrusiveJavaScriptEnabled to false as shown in the following code sample.

<add key="UnobtrusiveJavaScriptEnabled" value="false" />

Note: You can skip this by referencing the ej.unobtrusive.min.js in the _Layout.cshtml file, as shown in the following image.

Layout.cshtml file | ASP.NET MVC Reporting Tools
Layout.cshtml file
  1. Reference scripts and CSS.
  1. While installing the BoldReports.JavaScript NuGet package, the scripts required to render the Report Viewer control will be added in the Scripts folder. The CSS files are added to the Content folder.
  2. Open the _Layout.cshtml page from the shared folder under Views and replace the following code in the head tag.
<!DOCTYPE html>
<meta charset="utf-8" />    
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>    
<div style="min-height: 600px;width: 100%;">        
<!--Render the gauge item. Add these scripts only if your report contains the gauge report item.-->    
<!--Renders the map item. Add this script only if your report contains the map report item.-->
<!--Renders the chart item. Add this script only if your report contains the chart report item.-->    
<!-- Report Viewer component script-->    
@RenderSection("scripts", required: false)

The purpose of each script and CSS file is explained in the following table.

Name Details




Includes the UI theme for the JavaScript reporting control.





A common jQuery script used to render the Bold Reports JavaScript reporting widgets in the Report Viewer control.




Renders the chart item. Add this script only if your report contains the chart report item.


ej2-base.min.js Render gauge items. Add these scripts only if your report contains a gauge report item.


Renders the map item. Add this script only if your report contains the map report item.


Required to render the Bold Report Viewer component.




  1. Configure the script manager.

In the _Layout.cshtml page, use the reporting script manager in the body element that places the Report Viewer control initialization script on the webpage.

Note: To initialize the script properly, the script manager should be included at the end of the body element, as shown in the following code sample.

<!-- Bold Reports script manager -->
  1. Initialize the Report Viewer component.

Open the index.cshtml page from the home folder under views and replace it with the following code to initialize the Report Viewer control.

  1. Add a sample report.
  1. Create a folder named Resources in the root folder of your application. This is where you will keep the RDL reports.
  2. Add an already created report. For example, sales-order-details.rdl.
  1. Configure the Web API.

The ASP.NET MVC Report Viewer requires a Web API service to render the Report Viewer control.

  1. Right-click the controller folder, select Add, and then select New Item from the context menu.
  2. In the Add New Item dialog, select Web API Controller class, name it ReportViewerController.cs, then click Add.
  3. In the ReportViewerController.cs file, add the BoldReports.Web.ReportViewer namespace.
  4. You need to inherit the IReportController interface and then implement its methods. Replace the following code in the newly created Web API controller.
public class ReportViewerController : ApiController, IReportController
    // Post action for processing the RDL/RDLC report.
    public object PostReportAction(Dictionary<string, object> jsonResult)
        return ReportHelper.ProcessReport(jsonResult, this);
    // Get action for getting resources from the report.
    public object GetResource(string key, string resourcetype, bool isPrint)
        return ReportHelper.GetResource(key, resourcetype, isPrint);
    // Method that will be called when initializing the report options before processing the report.
    public void OnInitReportOptions(ReportViewerOptions reportOption)
        // You can update report options here.
    // Method that will be called when reported is loaded.
    public void OnReportLoaded(ReportViewerOptions reportOption)
        //You can update report options here.

IReportController has a declaration of action methods that are defined in the Web API Controller for processing the RDL, RDLC, and SSRS reports and for handling requests from the Report Viewer control. The IReportController has the following action methods declaration.

Methods Description
PostReportAction Action (HttpPost) method for posting the requests from client to server for processing the report.
OnInitReportOptions This method is invoked when the report is about to be processed.
OnReportLoaded The report loaded method occurs when the report and subreport started to load.
GetResource Action (HttpGet) method is used to get image resources for the report.

ReportHelper contains helper methods that help to process a Post or Get request from the Report Viewer control and return the response to the Report Viewer control. It has the following methods.

Methods Description
ProcessReport Processes the report request and returns the result.
GetResource Returns the report resource to the requested key.
  1. Add routing information.

Routing is the process of directing an HTTP request to a controller. The functionality of this processing is implemented in System.Web.Routing.
The action parameter names the action method on the controller used to map the method in the controller.

  1. From the App_Start folder, open the WebApi.Config.cs file of your application.
  2. Modify the route template in the register method to include the “action” parameter in the URL as shown in the following code sample.
public static class WebApiConfig
    public static void Register(HttpConfiguration config)
        // Web API configuration and services.
        // Web API routes.
        name: "DefaultApi",
        routeTemplate: "api/{controller}/{action}/{id}",
        defaults: new { id = RouteParameter.Optional }
  1. Set the report service URL and report path.

The ReportPath property sets the path of the RDL report file while the ReportServerUrl property specifies the report Web API service URL.

  1. Open the index.cshtml page and set the ReportServiceUrl and ReportPath properties. Replace the following code on your Report Viewer page.
  1. Build and run the application to view the report in the Report Viewer as displayed in the following image.

    View the report in the Report Viewer | ASP.NET MVC Reporting Tools
    View the report in the Report Viewer


I hope this blog has provided knowledge on how you can add the Report Viewer to an ASP.NET MVC application. Look at Bold Reports demo samples and documentation site to learn more. If you have any questions, please post them in the comments section. You can also contact us through our contact page or, if you already have an account, you can log in to ask your support question.

Bold Reports offers a 15-day free trial that does not require a credit card. We invite you to sign up and experience Bold Reports for yourself. Give it a try and let us know what you think!


Share this blog

Leave a Reply

Your email address will not be published. Required fields are marked *