Add a JavaScript-Based Report Designer to a Blazor Web App (Interactive Server)
- 6 minutes to read
This tutorial adds the Report Designer control (DxReportDesigner) to a Blazor Web App (Interactive Server) template.
Create a New Project
This section describes how to create a new Blazor project. If you want to start this tutorial using an existing application, go to Step 2.
Click Create a new project on Visual Studio’s start page and select the Blazor Web App template. Select Server from the Interactive Render Mode drop-down list.

Click Next.
Specify the project name and location, and click Next.
Specify additional options and click Create.
For additional information on available Blazor templates, refer to the following topic: Tooling for ASP.NET Core Blazor.
Install NuGet Packages
Install NuGet packages for Blazor Reporting:
Select Tools → NuGet Package Manager → Manage NuGet Packages for Solution.
In the invoked dialog, open the Browse tab, and install the following NuGet packages:
DevExpress.Blazor.Reporting.JSBasedControlsDevExpress.AspNetCore.Reporting
The DevExpress 25.2 Local package is automatically added as a package source to your NuGet configuration files if you used the DevExpress .NET Product Installer.
Build the project.
Refer to the following topic for more information: Install NuGet Packages in Visual Studio, VS Code, and Rider.
Register DevExpress Resources
Register the services required for Blazor Reporting, and specify endpoint routing. For this, call the following methods in the Program.cs file:
using DevExpress.Blazor.Reporting; using DevExpress.XtraReports.Web.Extensions; // ... builder.Services.AddMvc(); builder.Services.AddDevExpressBlazorReporting(); // ... app.UseDevExpressBlazorReporting();Register DevExpress.Blazor and DevExpress.Blazor.Reporting namespaces in the _Imports.razor file:
@using DevExpress.Blazor @using DevExpress.Blazor.ReportingIn the App.razor file, call the RegisterScripts(Action<ResourcesConfigurator>) method to register DevExpress client resources:
<head> @*...*@ @DxResourceManager.RegisterScripts() @*...*@ </head>
Add a Report Storage
Implement a ReportStorageWebExtension descendant to load and save reports.
Important
This tutorial uses the file system to store reports for demonstration purposes only. In a production application, use a database or other secure storage to save reports. For more information, refer to the following help topic: Add a Report Storage.
The following code is a sample storage that uses the file system to store reports. Add the CustomReportStorageWebExtension.cs class file to your project with following content:
using DevExpress.XtraReports.UI; using System.ServiceModel; public class CustomReportStorageWebExtension : DevExpress.XtraReports.Web.Extensions.ReportStorageWebExtension { readonly string reportDirectory = "Reports"; const string FileExtension = ".repx"; public CustomReportStorageWebExtension() { if (!Directory.Exists(reportDirectory)) { Directory.CreateDirectory(reportDirectory); } } public override bool CanSetData(string url) { // Determines whether a report with the specified URL can be saved. // Add custom logic that returns **false** for reports that should be read-only. // Return **true** if no valdation is required. // This method is called only for valid URLs (if the **IsValidUrl** method returns **true**). return true; } public override bool IsValidUrl(string url) { // Determines whether the URL passed to the current report storage is valid. // Implement your own logic to prohibit URLs that contain spaces or other specific characters. // Return **true** if no validation is required. return Path.GetFileName(url) == url; } public override byte[] GetData(string url) { // Uses a specified URL to return report layout data stored within a report storage medium. // This method is called if the **IsValidUrl** method returns **true**. // You can use the **GetData** method to process report parameters sent from the client // if the parameters are included in the report URL's query string. try { if (Directory.EnumerateFiles(reportDirectory).Select(Path.GetFileNameWithoutExtension).Contains(url)) { return File.ReadAllBytes(Path.Combine(reportDirectory, url + FileExtension)); } } catch (Exception) { throw new FaultException(new FaultReason("Could not get report data."), new FaultCode("Server"), "GetData"); } throw new FaultException(new FaultReason(string.Format("Could not find report '{0}'.", url)), new FaultCode("Server"), "GetData"); } public override Dictionary<string, string> GetUrls() { // Returns a dictionary that contains the report names (URLs) and display names. // The Report Designer uses this method to populate the Open Report and Save Report dialogs. return Directory.GetFiles(reportDirectory, "*" + FileExtension) .ToDictionary(x => Path.GetFileNameWithoutExtension(x)); } public override void SetData(XtraReport report, string url) { // Saves the specified report to the report storage with the specified name // (saves existing reports only). var resolvedUrl = Path.GetFullPath(Path.Combine(reportDirectory, url + FileExtension)); if (!resolvedUrl.StartsWith(Path.GetFullPath(reportDirectory) + Path.DirectorySeparatorChar)) { throw new FaultException("Invalid report name."); } report.SaveLayoutToXml(resolvedUrl); } public override string SetNewData(XtraReport report, string defaultUrl) { // Allows you to validate and correct the specified name (URL). // This method also allows you to return the resulting name (URL), // and to save your report to a storage. The method is called only for new reports. SetData(report, defaultUrl); return defaultUrl; } }In Program.cs, register the
CustomReportStorageWebExtension:using DevExpress.XtraReports.Web.Extensions; // ... builder.Services.AddDevExpressBlazorReporting(); // ... builder.Services.AddScoped<ReportStorageWebExtension, CustomReportStorageWebExtension>();Important
Register the
ReportStorageWebExtensionservice after theAddDevExpressBlazorReportingmethod.Add a new Reports folder to a project. The folder name should be specified in the
ReportStorageWebExtensionimplementation.
Create a Sample Report
To perform this step, you should install DevExpress Reporting v25.2 on your machine. Refer to the following topic for more information: Run the Installation Wizard - DevExpress Unified Component Installer.
Select Project -> Add New Item… to invoke the Add New Item dialog. Navigate to the Reporting node and select the DevExpress v.25.2 Report item template.

Name the report TestReport.cs and click Add.
Select Blank in the invoked Report Wizard page and click Finish.

Modify the newly created report in the Visual Studio Report Designer. Add a label and type Hello, World!:

Click the report’s smart tag and select Save…:

In the invoked Save As dialog, specify the Reports project folder, Report XML Files (.repx) file type, and the TestReport.repx file name.
Add a Report Designer to a Page
Create a new razor file (ReportDesigner.razor) in the Pages folder. Use the code below to generate a page with a Report Designer component.
Enable interactivity for DevExpress components:
Make sure the required interactive services are registered.
Add an appropriate render mode attribute to a component’s page.
@page "/reportdesigner"
@rendermode InteractiveServer
<DxReportDesigner ReportName="TestReport" Height="1000px" Width="100%">
</DxReportDesigner>
The DxReportDesigner loads the TestReport report.
Note
If you implement a custom report that inherits from XtraReport and want to open it in the End-User Report Designer, add a constructor without parameters to this report.
Add Navigation Links
Add navigation links to the NavMenu.razor page:
Run the Project
Run the project. The Report Designer component loads the TestReport.repx report:

Next Steps
- Use Data Sources
- Learn how to use data sources in the JavaScript-based Report Designer.
- Customize the Report Designer UI and Behavior
Refer to the following topics to learn how to customize the Report Designer UI and behavior:
- Troubleshooting
- This topic lists common issues that can occur in a Web Reporting application and describes solutions. For information on how to identify the cause of an issue, refer to the following topic: Reporting Application Diagnostics.