ActiveReports 14 .Net Core DataSet Provider

Posted by: emaibach on 19 August 2020, 4:09 pm EST

  • Posted 19 August 2020, 4:09 pm EST

    I am using ActiveReports 14 in a .Net Core 3 ASP.Net Web API application with the Angular viewer. How would I go about adding JWT authorization? I am not seeing a way to access the controllers used for serving the reports.

  • Posted 20 August 2020, 7:10 am EST

    Hello,

    Can you please explain a bit more on how do you wish to implement JWT authorization with ActiveReports? What’s your application’s structure like and where is the data coming from? Please provide as much details as possible and sending across a sample application and screen shots would be really helpful.

    Thanks

  • Posted 20 August 2020, 8:00 am EST

    In the Startup.ConfigureServices method of our application we use the services.SetupJwtBearerAuthenticationServices method to setup JWT authentication with auth0.com.

    Then on our controllers, we add the [Authorize] attribute to the controller class, and on each controller method we add a custom [Perimssion] attribute that we created that checks to see if the user has the necessary role to call that particular API method.

    My apologies, I am not able to post our code on a forum.

    So normally we would just add these attributes to the controller class and the controller methods. My hope was I could just override the ActiveReports controller classes, add the attributes, and then in the controller methods call the base method. But I have not been able to figure out how to do that.

  • Posted 21 August 2020, 4:03 am EST

    Hello,

    You can try with the following lines of code that allows chain request handlers.

    public static string EmbeddedReportsPrefix = "JSViewerMiddleware.Reports";
     public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
            {
                if (env.IsDevelopment())
                {
                    app.UseDeveloperExceptionPage();
                }
                Func<string, object> getCustomStorage = null;
                app.UseWhen(context => UriHelper.GetEncodedUrl(context.Request).Contains("/api/reporting"), (app) =>
                 {
                    app.Use(async (context, next) =>
                    {
                        getCustomStorage = (reportId) =>
                        {
                            // here we have access to the http context!
                            // we can extract parameters, check presence of auth tokens, et cetera!
                            var url = UriHelper.GetEncodedUrl(context.Request);
                            using (var reportStream = typeof(Startup).Assembly.GetManifestResourceStream($"JSViewerMiddleware.Reports.{reportId}"))
                            using(var reader = new System.IO.StreamReader(reportStream))
                            {
                               var def = new PageReport(reader);
                               return def.Report;
                            }
                        };
                        await next.Invoke();
                    });
                 });
                app.UseReporting(settings =>
                {
                    settings.UseEmbeddedTemplates(EmbeddedReportsPrefix, Assembly.GetAssembly(GetType()));
                    settings.UseCompression = true;
                    settings.UseCustomStore((reportId)=>
                    {
                        return getCustomStorage(reportId);
                    });                
                });
                app.UseMvc();
            }
    

    Also, you can open a case on our private forum to share your code:

    https://supportone.componentone.com/newcase

    You can login to above link using forum credential.

    Hope it helps.

    Thanks,

    Mohit

  • Posted 24 August 2020, 10:13 am EST

    When I implemented this custom storage method the reports no longer display in the UI, instead the UI gives a error that says 'Value cannot be null. (Parameter ‘stream’). I stepped through the code in debug mode and I am not seeing an obvious issue, it seems to be retrieving the report successfully.

    I have attached my Web API project and the Angular front end web app.

    AngularApp.zipWebAPIProject.zip

  • Posted 25 August 2020, 8:03 am EST

    Hello,

    I have escalated the issue to the development team(AR-24403) and will inform you once I get any information from them.

    Thanks,

    Mohit

  • Posted 25 August 2020, 10:31 am EST

    Hello,

    It is the known issue with CSV provider report. Could you please check with another report.

    Thanks,

    Mohit

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels