Integrating jsreport.local and jsreport.client in Web API 2.0

  • Hello,

    We currently have jsreport running successfully in a Web API. However it is extremely slow when rendering, much more so than directly from the report studio.

    Looking over the .net examples the developer who originally coded the initialization used the one for the console application. The below code is called on every report render, which I think is incorrect.

             var rs = new LocalReporting()
                .RunInDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar.ToString() + @"bin", "jsreport"))
                .Configure(cfg => cfg.AllowLocalFilesAccess().FileSystemStore().BaseUrlAsWorkingDirectory())
           var report = rs.RenderByNameAsync(ReportName, reportData).Result;
            MemoryStream ms = new MemoryStream();
            return ms.GetBuffer();

    I think the first block of code should be on the application initialization or start-up but the only example I found that shows how to initialize it there is for a .net core application.

    Any help would be greatly appreciated.

    Thank you,

  • Yes, you should reuse the rs in your case and call only rs.RenderByNameAsync when it is required to render something.

    If it is still slow, you can try this.

Log in to reply

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.