Step-by-Step Tutorial on Rendering an RDLC Report in an ASP.NET MVC Application

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hello everyone, Welcome to this new video on rendering an RDLC report in an ASP.NET MVC application. An RDLC report is an XML based file that contains the report layout parameters and other report related information. RDLC reports are designed to pass data reports from applications. Four items should be set to render an RDLC report in ASP.NET MVC Report Viewer. They are, Reporting Service: This API is used to interact with server side report processing. Processing Mode: This API specifies whether to process reports in the local or remote mode. Reports will be processed as RDL if the processing mode is set to remote and RDLC if it is set to local. Report Path: This API is used to set the path of the report that is to be rendered in the ASP.NET MVC Report Viewer. Data Sources: These are used to assign the required data to the report. First let me create a new ASP.NET MVC web application. I open Visual Studio 2022 and click create a new project. Select the ASP.NET webapplication (.NET Framework), and I click the Next button. Change the name to MVCRDLCReport Viewer, then click the Create button. In the Create a new ASP.NET Web Application dialog, I select MVC, check the Web API checkbox, and then click Create. See an ASP.NET MVC web application has been created. Next I need to install the required NuGet packages and assembly references. In the Solution Explorer tab, I right click the project or solution and choose Manage NuGet Packages. In the Browse tab, search for the BoldReports. Web package and install it in the MVC application. In the same way I install BoldReports.MVC5 and BoldReports.JavaScript packages. I have mentioned the purpose of each package in the table. The BoldReports.Web package creates Web API services to process reports. The BoldReports.MVC5 package contains tag helpers to create a client side Report Viewer control. The BoldReports. JavaScript package contains reporting components, scripts and style sheets. Next I open the Web.config file from the Views folder and add the BoldReports.Mvc assembly reference to the system.web .webpages.razor element. Then open the Web.config file from the root directory. Set UnobtrusiveJavaScript Enabled to false. If you want to use UnobtrusiveJavaScript Enabled then add a reference to the el.unobtrusive.min.js script in your application. You can refer to the script from the installed location. Now let me refer the scripts and styles to render the Report Viewer control. I open _Layout.cshtml from the Views/Shared folder, then copy the necessary scripts for the documentation and add it after removing the existing code. For this video, I am using local scripts and a style sheet. Now let me configure the Script manager in _Layout.cshtml. Add the script manager at the end of the body tag. Next, I initialize the Report Viewer control. The control can be added using the bold tag. Open the Index.cshtml file from the Views/Home folder and add the Bold.ReportViewer tag to render the control. Next, create a folder named Resources in the application root folder of my application. This is where RDLC reports are stored. For this video, I'm going to add the product-list.rdlc file to the Resources folder. You will find the product-list.rdlc file link in the video description for RDLC reports, provide data from the application. Next, create a class file named ProductList.cs in the application root folder. In the ProductList.cs add the necessary using statement. Copy the code from the documentation and paste it inside the ProductList class. Next I need to configure the Web API. The ASP.NET MVC Report Viewer requires a Web API service to process RDL, RDLC and SSRS report files. I create a new file and name it ReportViewerController.cs inside the Controller folder. In the controller file I add the necessary using statement, then inherit IReportController. I copy the necessary variables and methods from the documentation and paste them inside the ReportViewerController class. In the OnInitReportOptions method, first set the processing mode to Local. Here I am going to load the report as a stream. To do that I create a variable named report path and combine the folder path value that has the report with the report path sent from the Index.cshtml. Next create an instance for the filestream and assign the file path to it. I create a memory stream and copy the filestream value in it. Then assign the report stream stream value to the reportOption .ReportModel.Stream variable. I add the Data value collection to the DataSource value. Here Name is case sensitive and it should be the same as the datasource name in the report definition. The value accepts IList, Dataset and Datatable inputs. I save the file. Then I open the WebApiConfig.cs file from the App_Start folder and modify the root template in the Register event to include the action parameter in the URL. Next, I register the license token to remove the license validation message. In this demo, I am going to use the online license token. License tokens can be generated in the Subscription section of the Bold Reports Accounts page. Open the Global.asax.cs file and enter the code snippet to register the license token. I have provided the link to a video on registering a license using online license tokens and offline license keys. In this video's description, let's move on to showing the product-list.rdlc. With the report viewer, I open the Index.cshtml page, and set the report-service-Url. This URL should be one that was created by using the IReportController for the Report Viewer. Next I set the report-path for the report that needs to be loaded. The product-list.rdlc file was already placed within the application and I will be using its report path for this demo. I saved the file. Now everything is set to render the RDLC report from the ASP.NET MVC application. I build and run the application, see the report is loaded in the browser. In this video you saw how to create an ASP.NET MVC application, how to reference the required scripts to render an RDLC report and how to declare variables to bind the data source from the Web API controller to render the report. I have provided A documentation link in the description below for the steps that were followed in this video. I have also provided a link to our article on enabling image rendering with the Report Viewer on Linux and other non Windows platforms for your reference. If you found this video useful, don't forget to click the like button and subscribe to our channel to watch more videos like this. Thanks for watching.
Info
Channel: Bold Reports
Views: 1,474
Rating: undefined out of 5
Keywords: bold reports, bi reporting tool, ssrs, ssrs reporting tool, bi reporting software, reporting tools, business intelligence reports, render rdlc report to ASP.NET MVC application, ASP.NET MVC report viewer, rdlc, render rdlc report, render rdlc report in ASP.NET MVC application
Id: nOD5jjjpr-E
Channel Id: undefined
Length: 9min 31sec (571 seconds)
Published: Fri Jul 21 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.