Issue with FastReport OpenSource in .NET Core 9 & Angular

Discussão em 'Angular' iniciado por Parth M. Dave, Março 24, 2025.

  1. I'm using FastReport OpenSource (2025.1.0) in a .NET Core 9 backend project along with Angular-17 for the frontend. I have installed the necessary dependencies:

    • FastReport.OpenSource
    • FastReport.OpenSource.Export.PdfSimple
    • FastReport.OpenSource.Web

    Backend API (Report Generation) I have an API endpoint that generates reports and returns HTML content:

    [HttpGet("CustomerListReport")]
    public async Task<IActionResult> GenerateCustomerListReport(string reportName)
    {
    WebReport webReport = new WebReport();
    webReport.Width = "100%";

    var dataTable = customerServices.CustomerReportData(1); // Fetch report data

    string reportPath = Path.Combine("App_Data\\ReportFile", $"{reportName}.frx");
    webReport.Report.Load(reportPath);
    webReport.Report.RegisterData(dataTable, reportName);
    webReport.Report.Prepare();

    var htmlContent = webReport.Render().Result.Value;
    return Content(htmlContent, "text/html");
    }


    Frontend Code (Fetching Report) The Angular frontend retrieves the report HTML and embeds it into an iframe:

    this.DashboardService.getReportUrl().subscribe((htmlContent: any) => {
    const iframe = document.getElementById('reportIframe') as HTMLIFrameElement;
    const iframeDoc = iframe.contentDocument || iframe.contentWindow?.document;
    if (iframeDoc) {
    iframeDoc.open();
    setTimeout(() => {
    iframeDoc.write(htmlContent);
    iframeDoc.close();
    }, 100);
    }
    });

    <iframe #report id="reportIframe" height="1000" width="100%"></iframe>


    Issue

    Backend API runs on: https://localhost:44393/api

    Frontend runs on: https://localhost:4200

    The report does not render in the iframe.

    I noticed that FastReport tries to call an API at https://localhost:4200/fr/preview.Report, but it should be calling https://localhost:44393/fr/preview.Report.

    How can I configure FastReport to use the correct backend URL (https://localhost:44393) instead of trying to call the frontend URL (https://localhost:4200)? Any help would be greatly appreciated!

    Continue reading...

Compartilhe esta Página