Hello,
I have a regular report in my asp.net core 2.2 with 1 picturebox and 3 checkboxs. Works #1.
I create a new asp.net core 3.0 (copying everything from 2.2). My picturebox and the 3 squares of the checkboxs (but the labels are ok) are not anymore display in the reportViewer (javascript). When i generate a PDF version everthing worked.
Telerik.Reporting v13.2.19.920-hotfix (same problem with 13.2.19.918)
Telerik.Reporting.Services.AspNetCore v13.2.19.920-hotfix (same problem with 13.2.19.918)
Any idea?
6 Answers, 1 is accepted
Hi Louis,
I noticed that you opened a support ticket on the same issue. I will summarize our communication also here for the benefit of our community.
The exception message associated with the problem is "Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead". The problem is described in the .Net Core 3 preview: Synchronous operations are disallowed Stackoverflow thread. The solution can be found in the same thread. You need to manually set AllowSynchronousIO to true in Startup.cs file for IIS. The ConfigureServices class may look like:
public void ConfigureServices(IServiceCollection services)
{
this.services = services;
this.services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.Configure<IISServerOptions>(options =>
{
options.AllowSynchronousIO = true;
});
this.services.AddSingleton<ConfigurationService>();
this.services.AddRazorPages()
.AddNewtonsoftJson();
}
For Kestrel you need to use the following code:
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureKestrel((context, options) =>
{
options.AllowSynchronousIO = true;
})
Regards,
Todor
Progress Telerik

Synchronouse API. As docs says:
> AllowSynchronousIO enables or disables synchronous IO APIs, such as HttpRequest.Body.Read, HttpResponse.Body.Write, and Stream.Flush. These APIs are a source of thread starvation leading to app crashes.
Do you have any plans to use await WriteAsync instead of Write in Reporting code?

The simple change
public
virtual
void
GetResource
to
public
virtual
async Task GetResource
await this.Response.Body.WriteAsync
or
public virtual Task GetResource
return this.Response.Body.WriteAsync
Hi Marcin,
Thank you for the suggestion. We will discuss it in the team whether it is appropriate and possible to make the requests for the resources asynchronous.
Regards,
Todor
Progress Telerik

I simply overriden 1 method in class inheriting from ReportsControllerBase and all is working without enabling SychronousIO:
/// <summary>
/// </summary>
[AllowAnonymous]
[HttpGet(
"old/clients/{clientID}/instances/{instanceID}/documents/{documentID}/resources/{resourceID}"
)]
public
override
void
GetResource(
string
clientId,
string
instanceId,
string
documentId,
string
resourceId)
{
base
.GetResource(clientId, instanceId, documentId, resourceId);
}
/// <summary>
/// </summary>
[AllowAnonymous]
[HttpGet(
"clients/{clientID}/instances/{instanceID}/documents/{documentID}/resources/{resourceID}"
)]
public
async Task GetResourceAsync(
string
clientId,
string
instanceId,
string
documentId,
string
resourceId)
{
var propertyInfo =
typeof
(ReportsControllerBase).GetProperties(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly).Single(p => p.Name ==
"Engine"
);
var engine = (IReportEngine)propertyInfo.GetValue(
this
);
var resource =
engine.GetResource(clientId, instanceId, documentId, resourceId);
var data = resource.Bytes;
await
this
.Response.Body.WriteAsync(data, 0, data.Length);
}
Hi Marcin,
Thank you for your efforts and provided solution for obtaining the resources asynchronously. You are right - it seems pointless to keep using the synchronous operations when async ones are available. Although the problem arises only when using .NET Core 3, I believe it makes sense to change it for all the frameworks after proper testing. Your suggestion is already logged for discussion and implementation. Since we highly appreciate ideas that help you further develop our product, as a token of gratitude we updated your Telerik points.
Regards,
Ivan Hristov
Progress Telerik