[]
This guide walks you through configuring the Report Viewer middleware in an ASP.NET Core application. You’ll learn how to install the required packages, register services, and set up the middleware to enable report viewing functionality.
Before setting up the Report Viewer middleware, ensure that the following NuGet packages are installed in your project:
These packages provide the necessary components for integrating the Report Viewer into your ASP.NET Core application.
To integrate the Report Viewer middleware in an ASP.NET Core application, follow these steps:
Open the Program.cs file in your project.
Register character encodings to ensure proper text rendering by adding System.Text.Encoding.RegisterProvider.
Register the Report Viewer service using AddReportViewer in the IServiceCollection section.
Add the Report Viewer middleware to the request pipeline by calling UseReportViewer.
Below is a sample configuration for setting up the middleware in Program.cs:
using GrapeCity.ActiveReports.Aspnetcore.Viewer;
using System.Text;
// Register character encodings
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
// Create the WebApplication builder
var builder = WebApplication.CreateBuilder();
// Register the Report Viewer service
builder.Services.AddReportViewer();
var app = builder.Build();
// Add the Report Viewer middleware to the request pipeline
app.UseReportViewer(config =>
{
// Optional: Configuration options for the report viewer
});
// Run the application
app.Run();After adding the Report Viewer middleware, the next step is to configure it to meet your application’s needs. For a complete guide on the available configuration options, continue to the Middleware Configuration Options.