I'm fairly consistently getting a 503.0 error (server has been shutdown) when working with Telerik reports. This is an ASP.NET Core application, currently with a single report with 2 sub-reports. I've published the application to a test Azure app service and that fails pretty consistently when trying to preview the report each time. On most occasions the report opens but as soon as I switch to print preview I receive a report that the service has shutdown with a 503.0 error - racing shows this to be with ASPNetCoreModuleV2.
If I run the application in debug mode from my VS2017 on Windows 10 using IISExpress and Firefox browser, the application works fine and I can navigate around without any issues. If I then run the report it opens and displays correctly. I can switch to print preview and mostly that also shows correctly but when I try to export to PDF I get the 503.0 error. Sometimes the error will come up at print preview stage. The report runs from a SQL data source using a stored procedure. The 2 sub-reports run from separate stored procedures. They are all set to use the same application "ReportsConnection", passing 2 parameters to the report and consequent stored procedure. Can you provide some advice on what might be causing this problem or what to investigate to try to identify the issues?
22 Answers, 1 is accepted
This is a new issue for us. The strange thing is that, if I understood correctly, the PDF export and Print Preview may work correctly or may fail when the application is deployed in Azure. The observed 503 error is also a new issue for us as it indicates unavailable service. Could you sent a trace log of the error - you may check how to set up a Trace Listener in .NET Core in the Troubleshooting reporting implementation into ASP.NET Core application KB article.
Additionally, you may check the following threads for possible approaches for tackling the problem.
Troubleshoot HTTP errors of "502 bad gateway" and "503 service unavailable" in Azure App Service
Aspnetcore deployment to App Service targeting .net framework cause error until AspNetCoreModuleV2 is switched back to AspNetCoreModule
Regards,
Todor
Progress Telerik



Sorry, hit post too soon. I setup the trace and the tail part of the log is below - note there are no errors recorded anywhere in the log file - it just ends when the app hits 503:
Worker rendering threads count: 12
----------------------
Cache cleaning started
12/06/2019 11:39:28
Check period: 00:05:00
1 Refreshes 00:00:00.1179746
0 ReportInstances 00:00:00.0000023
1 Clients 00:00:00.0039295
Total cache clean time: 00:00:00.1864792
SolutionNamexxxx Information: 0 : Unit.DotsPerInch = 96
Rendering thread 42 starts work.
*** ReportProcessor.ProcessReport STARTED ***
*** ProcessReport #0 STARTED ***
*** ProcessReport #0 DONE in 00:00:00.3725415 ***
*** ReportProcessor.ProcessReport DONE in 00:00:00.4198504 ***
*** RenderReport #0 STARTED ***
*** RenderReport #0 DONE in 00:00:00.3088494 ***
Rendering thread 42 finishes work.
Rendering thread 42 starts work.
*** ReportProcessor.ProcessReport STARTED ***
*** ProcessReport #0 STARTED ***
*** ProcessReport #0 DONE in 00:00:00.0267524 ***
*** ReportProcessor.ProcessReport DONE in 00:00:00.0380915 ***
*** RenderReport #0 STARTED ***
*** RenderReport #0 DONE in 00:00:00.4467759 ***
Rendering thread 42 finishes work.

According to the trace log the report has been processed and rendered server-side correctly, with no issues. Therefore, I assume that the problem may indeed happen when delivering it. What is the Storage type you use for the REST Service? After rendering successfully, the response to the Get Document Info request (on the screenshots I see that it is the one that fails) should be 200 OK, and the next request should be made for the document itself or its first page - Get Document Page or Get Document. Have you overridden some of our methods in the ReportsController?
You may check the Windows Event Viewer for additional information on the problem.
Fiddler may also give further details. You may send us the SAZ files recorded by Fiddler for local investigation.
Since the problem occurs also on IISExpress locally and is not specifically related to Azure, consider opening a support ticket and sending a runnable project for local investigation.
Regards,
Todor
Progress Telerik

Hi Todor.
I'm using the default FileStorage and I can see it creating a large hierarchy of files in the path I've requested locally. I did find an issue in the Event Viewer (id 2264) relating to Static Compression and that seemed to be caused because the path it was trying to access wasn't there. I created the related folder and ensured the security was correct and the warning went away but the problem hasn't. It's still absolutely consistent that any attempt to export to PDF when running in IISExpress fails by taking down the app pool it would appear so giving a 503.0 error. I also noted that my main project assembly and namespace were not the same and that was showing a difference in places so I've been and changed everything to be absolutely consistent for namespace and assembly and that has also had no impact on the issue. I will look at Fiddler and come back once I have.
The warning in the Event Viewer may not be related to the problem.
I hope the information from Fiddler would shed more light on the issue.
Regards,
Todor
Progress Telerik



The XPS rendering is not supported for pure .NET Core projects - check Implemented Features and Limitations. This is due to technical difficulties with the implementation in .NET Core. Adding the XPS rendering for .NET Core is not in our immediate plans for the same reason. Our Azure demo is a .NET Framework project and XPS is available there.
Regards,
Todor
Progress Telerik

Hi Todor and thanks for your response. I have to say I understand that this issue is most likely documented in your Implemented Features and Limitations but considering how long I've been reporting this 503 error and the fact it's been trying to export to PDF that I'm a little surprised it has taken this long to get this particular key bit of information. That being said, we now have a .NET Core application hosted in Azure that will produce a report that can't be exported to PDF which is absolutely vital to the sign off of the project. Is there a simple change that can be made to achieve this? I have to admit this is the first .NET Core project we've done and while I've seen reference to targetting the full .NET Framework I'm not clear on what impact that would have on the rest of the project. Time is very much now of the essence so a quick response would be very much appreciated.
Thanks in advance
The issue with PDF export not working is not known for us and we were not able to reproduce it until now. Our demos work correctly and export successfully to PDF. You may try to adjust your project according to them.
The best that will work for us in order to investigate the problem will be a sample demonstrating it. We may be able to see something also in the Fiddler SAZ file recorded while the issue occurs. We would do our best to find out what is causing the error and how it could be fixed if you sent us any of those.
Note that we usually try to answer forum threads within 72 working hours. However, we do not guarantee a response in the forum.
If you want to be sure to receive an answer within 24 working hours, you should open a Support Ticket.
Regards,
Todor
Progress Telerik

Hi Todor.
I think we must be getting crossed wires here. The solution we have is an ASP.NET Core 2.2 web application with a SQL Azure backend database with Entity Framework Core for data access. We have a Telerik report viewer in the front end ASP.NET Core web app which will preview the report and from there we can export to Word and Excel. If we try to export to PDF it kills the web application and results in us receiving a 503.0 error and we have to restart the app service in the Azure management portal. Having delved deeper into what was going on via an Azure trace I picked up an entry telling me that we were missing the XPSRendering library - presumably used to produce the PDF export file. When I reported that I couldn't get the XPSRendering library into our solution you told me that XPSRendering is not supported "for pure .NET Core projects" and requires a full .NET Framework. So, what I'm simply trying to establish now is what is the easiest way to be able to retain all the development effort that's been expended on this project (and the cost of the Telerik licence of course) with the Telerik Reporting for producing the required reports and be able to export those reports to PDF? This project is in beta with the client testing all basic functionality and currently the only thing that doesn't work is the ability to export reports to PDF. How do we resolve this?
I will log a separate support ticket but if the answer will just be that XPSRendering is not support on pure .NET Framework projects then I'm not sure how much benefit that will be to anyone.
I have replied to the support ticket you opened on the topic. I will include the relevant part of my answer also here :
The XPS rendering is an extra functionality that requires Telerik.Reporting.XpsRendering.dll file that should be added manually to the project, e.g. our Visual Studio item templates do not add it automatically. The Reporting engine, when called, checks for the available external resources that are necessary for all the supported rendering formats. If an assembly that is required for any of the formats (e.g. Telerik.Reporting.XpsRendering.dll, Telerik.Reporting.OpenXmlRendering.dll) is missing, the engine will throw a first chance exception (i.e. passed to the debugger but not passed back to the application), which will be logged just to notify that the assembly is missing. This error will not distort in any way the workflow for the other renderings. Hence, PDF rendering does not depend on Telerik.Reporting.XpsRendering.dll file and the absence of this assembly cannot interfere with PDF rendering. In other words, the two problems are not related.
The PDF rendering logic is part of our main Telerik.Reporting assembly and does not require any additional assemblies, i.e. it is enabled by default with the installation of the product. PDF format is based on the IMAGE format - check PDF Rendering. Note that some Azure plans have restrictions related to the GDI+ that we use in IMAGE rendering - check GDI+ error or OutOfMemoryException on exporting or printing Telerik report from Azure WebSites KB article.
Regards,
Todor
Progress Telerik
I was getting the same 503.0 server error and the whole issue was very similar to yours. I've implemented the reporting service in our existing .NET Core MVC 2.2 project and the error came before the viewer could load the report, but sometimes I could even load some data before crashing, although the rendering was finished in all cases. It is really hard to recreate the problem in a separate project, because even the amount of data the report needs to load has an effect on when the shutdown occurs. And it is also hard to debug the issue.
What seems to be the solution here is calling the default webhost builder only once. So instead of using the ConfigurationService class in Startup.cs from the demo project, I can simply inject the configuration and hosting environment into the ReportsController like this:
public
ReportsController(IConfiguration configuration, IHostingEnvironment env)
If I try to run the CSharp.AspNetCoreDemo project with Kestrel only (e.g. dotnet run), I can't load the viewer, because it is complaining about the WebHostBuilder used inside ConfigurationService, but it runs fine by injecting the configuration directly like above.
I know it has been several months, but could you tell me how you injected the configuration to ReportsController in your project and let me know if the above did any help in your case?

Thank you for your reply. This is interesting. Using the method I mentioned above, the app worked fine with in process hosting, including pdf export. So I tried the old configuration and our app also produces the 503.0 error when I try to export pdfs. Having the same problem as you with exporting, I tried to run it with out-of-process hosting model as you suggested, which also worked fine. It seems like Kestrel can handle the situation where multiple IWebHosts are used in the same application, but IIS will fail at some point.
Can I ask how you get the configuration and inject it into the ReportsController currently?
Hi Adam,
The issue is known for us and is explained in Export to PDF fails from ASP.NET Core 2.2 projects KB article. Actually I think it is a bug in .NET Core 2.2 that is fixed in .NET Core 3.
You may see how we provide the configuration to the ReportsController in the following articles:
- How To: Use HTML5 Report Viewer in an ASP.NET Core 2.1 and 2.2 application
- How To: Use HTML5 Report Viewer in an ASP.NET Core 3+ application
Here is the sample code for .NET Core 3 (for .NET Core 2.1 and 2.2 it is slightly different):
public class ReportsController : ReportsControllerBase
{
...
public ReportsController(ConfigurationService configSvc)
{
...
this.ReportServiceConfiguration = new ReportServiceConfiguration
{
ReportingEngineConfiguration = configSvc.Configuration,
...
};
}
}
and here is our sample implementation of the ConfigurationService class:
public class ConfigurationService
{
public IConfiguration Configuration { get; private set; }
public IWebHostEnvironment Environment { get; private set; }
public ConfigurationService(IWebHostEnvironment environment)
{
this.Environment = environment;
var configFileName = System.IO.Path.Combine(environment.ContentRootPath, "appsettings.json");
var config = new ConfigurationBuilder()
.AddJsonFile(configFileName, true)
.Build();
this.Configuration = config;
}
}
and in the Configure method of the Startup class you add:
this.services.AddTransient(ctx => new Controllers.ReportsController(new ConfigurationService(env)));
Regards,
Todor
Progress Telerik
Hi Todor,
Thank you for your reply. I've seen that article about PDF exports, but your demos and our existing project that uses Reporting work fine with targeting .NET Core 2.2 and InProcess hosting. The only way I can reproduce the 503.0 error during PDF export was when I used this method below from your demo project to get the configuration and it was only occurring in our existing project.
//otherwise instantiate the default builder which will use the default appSettings.json and appSettings.{environment}.json files.
var defaultBuilder = Microsoft.AspNetCore.WebHost.CreateDefaultBuilder().Build();
var config = defaultBuilder.Services.GetService<IConfiguration>();
I would like to better understand the root of this problem, so I can be more confident about the fix and because we are planning to migrate more of our projects to .NET Core.
Regards.
Adam
Hi Adam,
Our demos are targeting .NET Core 2.1 and the issue does not occur there. I confirm that the issue is reproducible when our demo is upgraded to .NET Core 2.2 with InProcess. We haven't researched the issue further as we have found a workaround for .NET Core 2.2 and the problem does not exist in .NET Core 3. We assumed that the newly introduced feature is not mature enough in .NET Core 2.2. The way web.config gets generated seems modified, which may be related to the problem. You may check ASP.NET Core In Process Hosting on IIS with ASP.NET Core 2.2 for more information on the matter. Does your original project use configuration settings? We need also to try other ways to provide the configuration to the Reports Controller.
Regards,
Todor
Progress Telerik