ActiveReports 16 .NET Edition
ActiveReports 16 User Guide / Preview Reports / JavaScript / JSViewer ASP.NET Core Middleware
In This Topic
    JSViewer ASP.NET Core Middleware
    In This Topic

    ASP.NET Core middleware is a software to handle HTTP requests and response. Each middleware component serves a specific purpose like one middleware authenticates a user, the other middleware handles the static files like javascript or css files. These middleware components together setup a request processing pipeline.

    The request pipeline is configured in the Configure method in the Startup class. It is these middleware components in the pipeline that determine how a request is processed in ASP.NET Core. The default code developed by the ASP.NET Core Web App template sets up the request processing pipeline for the application using a set of middlewares - UseDeveloperExceptionPage() and UseStaticFiles() of IApplicationBuilder interface. The middlewares are executed in the order in which they are added to the pipeline.

    Copy Code
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
                if (env.IsDevelopment())

    To provide access to a report output from the browser, you need to configure ActiveReports JSViewer in ASP.NET Core middleware. It is done by adding the UseReporting() middleware in Configure method, which configures middleware for ActiveReports API and handlers.

    1. Create an ASP.NET Core Project

    2. Open Microsoft Visual Studio 2019 and select Create a new project.
      Create a New Project dialog

    3. Select ASP.NET Core Web Application.

      Create a New Project dialog

    4. Type a name for your project and click Create.
      Configure your New Project dialog

    5. Fill-in the additional info like Target Framework as .NET 5.0 (Current).

      Create a new ASP.Net Core Web Application dialog
    6. Uncheck the 'Configure for HTTPS' checkbox instruction and click Create.

      Configure ActiveReports in ASP.NET Core Middleware

    7. Right-click the project in the Solution Explorer and select Manage Nuget Packages.

    8. Add the following package to the project.

    9. Add a new folder called 'Reports' in application's root and place the report you want to display in the viewer, in this folder.

    10. Make sure to set the Build Action property of the report to 'Embedded Resource'.

    11. Open 'Startup.cs' file and add the following 'using' statement at the top.

      using GrapeCity.ActiveReports.Aspnetcore.Viewer;
    12. In the Startup.cs file, add the following code snippet inside the Configure method (before app.UseStaticFiles(); statement) to enable the application to use ActiveReports:

      Copy Code
      app.UseReporting(settings =>
            settings.UseEmbeddedTemplates("JsViewer_Core.Reports", this.GetType().Assembly);
            settings.UseCompression = true;

      Make sure that the correct namespace is provided in the first argument of UseEmbeddedTemplates for the report.