Error rendering after deploying to IIS on Windows Server 2008 R2 using ASP.Net Core



  • Installed nuget packages local, binary, and aspnetcore.

    Added this code to ConfigureServices in Statup.cs:

                var localWebServerReportingService = new LocalReporting()
                    .UseBinary(JsReportBinary.GetBinary())
                    .Configure(cfg => cfg
                        .AllowedLocalFilesAccess()
                        .FileSystemStore()
                        .BaseUrlAsWorkingDirectory()
                    )
                    .AsWebServer()
                    .Create();
                localWebServerReportingService.StartAsync();
                services.AddJsReport(localWebServerReportingService);
    

    Here is the code to render the file:

                    try
                    {
                        var viewHtml = await JsReportMvcService.RenderViewToStringAsync(HttpContext, RouteData, "InvoicePdf/InvoicePdf", invoiceGenerationModel);
                        var report = await JsReportMvcService.RenderAsync(new RenderRequest
                        {
                            Template = new Template
                            {
                                Recipe = Recipe.ChromePdf,
                                Engine = Engine.None,
                                Content = viewHtml,
                                Chrome = new Chrome
                                {
                                    Format = "Letter",
                                    MarginTop = "0.5in",
                                    MarginBottom = "0.5in",
                                    MarginLeft = "0.5in",
                                    MarginRight = "0.5in"
                                }
                            }
                        });
                        var memoryStream = new MemoryStream();
                        await report.Content.CopyToAsync(memoryStream);
                        memoryStream.Seek(0, SeekOrigin.Begin);
                        return memoryStream;
                    }
                    catch (Exception e)
                    {
                        _logger.LogError("Error generating pdf file!");
                        _logger.LogError(e.Message);
                        return null;
                    }
    

    On my development machine it works fine. On IIS I am getting this error:

    "Unable to render template. Timeout Error: pdf generation not completed after 30000ms"

    Any ideas?



  • Note that I also tried adding:

    .RunInDirectory(Path.Combine(Directory.GetCurrentDirectory(), "jsreport"))
    

    to the first code block and that didn't help.


Log in to reply
 

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