asp.net-corefastreport

How to display FastReport in Razor Pages


Iam using Razor Pages web app .Net Core 6. I have a report (FastReport) which i want to display on Page.

Here is the code: `

using FastReport.Report report = new ();
        var reportPath = _env.WebRootFileProvider.GetFileInfo("Reports/ConsumerStatement.frx")?.PhysicalPath;
        report.Load(reportPath);
        report.RegisterData(data, "RefData");` 

Everything is working fine. In .Net Core MVC reports is successfully displayed by: `return View(report);

but I cannot figured out how to display this report in Razor Pages because return Page() is not accepting any parameter.

How can i display this report in razor page??


Solution

  • Try pass the value to razor view with ViewBag/ViewData as the doc of FastReport,ViewBag/ViewData is accessable both in RazorPage and MVC projects

    in PageModel:

    ViewBag.Report=report;
    

    In RazorView:

    @ViewBag.Report.......