Quickly begin using ActiveReports by following the steps below.
In Microsoft Visual Studio 2022 (version 17.0 or above), select ActiveReports 17 JS Viewer Core MVC Application template.
Type a name for your project and click Create.
Modify index.html to provide the name of the report you want to preview in viewer.openReport() method:
viewer.openReport("RdlReport1.rdlx");
Modify Startup.cs to include the path of the folder where the report is kept, for example, if the 'Reports' folder in your application’s root contains the report. The complete Stratup.cs looks like below.
Startup.cs |
Copy Code
|
---|---|
using GrapeCity.ActiveReports.Aspnetcore.Viewer; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using System; using System.Reflection; using System.Text; namespace JSViewerCoreMVCApplication { public class Startup { public static string EmbeddedReportsPrefix = "JSViewerCoreMVCApplication.Reports"; // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); services .AddLogging(config => { // Disable the default logging configuration config.ClearProviders(); // Enable logging for debug mode only if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == Environments.Development) { config.AddConsole(); } }) .AddReporting() .AddMvc(option => option.EnableEndpointRouting = false); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseReporting(settings => { settings.UseEmbeddedTemplates(EmbeddedReportsPrefix, Assembly.GetAssembly(GetType())); settings.UseCompression = true; }); app.UseMvc(); } } } |
Run the application. The report opens in the JSViewer.