How to display FastReport in Razor Pages

  below code i try to display FastReport in Razor Pages

  [BindProperty]

    public HomeModel model { get; set; }



 public IActionResult OnGet(int? reportIndex = 0)

    {

      model = new HomeModel()

      {

        WebReport = new WebReport(),

        ReportsList = new[]

       {

          "Simple List"

        },

      };

      var reportToLoad = model.ReportsList[0];

      if (reportIndex >= 0 && reportIndex < model.ReportsList.Length)

        reportToLoad = model.ReportsList[reportIndex.Value];

       var reportPath = System.IO.Path.Combine(_hostingEnvironment.WebRootPath, "Reports");

      model.WebReport.Report.Load(System.IO.Path.Combine(reportPath, $"{reportToLoad}.frx"));

      var dataSet = new DataSet();

      dataSet.ReadXml(System.IO.Path.Combine(reportPath, "nwind.xml"));

      model.WebReport.Report.RegisterData(dataSet, "NorthWind");

      model.WebReport.Width = "1000";

      model.WebReport.Height = "1000";

      model.WebReport.Mode = WebReportMode.Preview;

      return Page();

    }

in View

  <div class="webreport">

    @await Model.model.WebReport.Render()

  </div>

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.