How to render active reports webviewer in asp net mvc

Introduction

ASP.NET is a popular programming language used for building web applications. One common in web development is to render Reports WebViewer in ASP.NET MVC. In this article, we will explore how to achieve this using ASP.NET MVC and provide examples to illustrate the process.

Step 1: Install Active Reports WebViewer

The first step is to install the Active Reports WebViewer package in your ASP.NET MVC . You can do this by using the NuGet package manager. Open the NuGet package manager and run the following command:

Install-Package GrapeCity.ActiveReports.WebViewer

Step 2: Add Active Reports WebViewer to View

Once the package is installed, you can add the Active Reports WebViewer to your ASP.NET MVC view. Open the view where you want to render the WebViewer and add the following code:

@Html.ActiveReportsWebViewer("ReportViewer1")

This code will render the Active Reports WebViewer with the ID “ReportViewer1” in your view.

Step 3: Configure Active Reports WebViewer

Next, you need to configure the Active Reports WebViewer to display the desired report. In your controller, an method that will handle the request to render the report. Here is an example:

 ActionResult RenderReport()
{
    // Load the report file
    var report = new GrapeCity.ActiveReports.SectionReport();
    report.Load("path/to/your/report.rdlx");

    // Set the report data source
    report.DataSource = GetReportData();

    // Render the report to the WebViewer
    ViewBag.ReportViewer1.Report = report;

    return View();
}

In this example, we load the report file from the specified path and set the data source for the report. Finally, we the report to the “ReportViewer1” in the ViewBag and return the view.

Step 4: Route the Request

To access the RenderReport action method, you need to a route in your ASP.NET MVC application. Open the RouteConfig.cs file in the App_Start folder and add the following code:

routes.MapRoute(
    name: "RenderReport",
    url: "RenderReport",
    defaults: new { controller = "YourController", action = "RenderReport" }
);

This code defines a route named “RenderReport” that maps to the RenderReport action method in your controller.

Step 5: Access the WebViewer

Now, you can access the Active Reports WebViewer by navigating to the URL defined in the route. For example, if your application is running on localhost, you can access the WebViewer by visiting “http://localhost/RenderReport”.

Conclusion

In this article, we have explored how to render Active Reports WebViewer in ASP.NET MVC. We have covered the installation process, adding the WebViewer to a view, configuring the WebViewer, routing the request, and accessing the WebViewer. By following these steps, you can easily Active Reports WebViewer into your ASP.NET MVC application and display reports seamlessly.

Rate this post

Leave a Reply

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

Table of Contents