Synchronous operations are disallowed.
Asp.net Core 3.0 üzerinde AllowSynchronousIO değeri False ise aşağıdaki gibi bir hata fırlatacaktır.
Eğer aşağıdaki gibi "Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead." mesajını alırsanız;
1
System.InvalidOperationException: Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.
2
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.Read(Byte[] buffer, Int32 offset, Int32 count)
3
at System.IO.StreamReader.ReadBuffer(Span`1 userBuffer, Boolean& readToUserBuffer)
4
at System.IO.StreamReader.ReadSpan(Span`1 buffer)
5
at System.IO.StreamReader.Read(Char[] buffer, Int32 index, Int32 count)
6
at Newtonsoft.Json.JsonTextReader.ReadData(Boolean append, Int32 charsRequired)
7
at Newtonsoft.Json.JsonTextReader.ReadData(Boolean append)
8
at Newtonsoft.Json.JsonTextReader.ParseValue()
9
at Newtonsoft.Json.JsonTextReader.Read()
10
at Newtonsoft.Json.JsonReader.ReadAndMoveToContent()
11
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
12
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
13
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
14
at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
15
at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)
16
at GraphQL.Server.Transports.AspNetCore.GraphQLHttpMiddleware`1.Deserialize[T](Stream s)
17
at GraphQL.Server.Transports.AspNetCore.GraphQLHttpMiddleware`1.InvokeAsync(HttpContext context)
18
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
19
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
20
Copied!
Program.cs dosyası içerisinde
1
.ConfigureKestrel((context, options) =>
2
{
3
options.AllowSynchronousIO = true;
4
});
Copied!
satırını eklemeniz yeterli olacaktır.
.net core 3.0 - program.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Threading.Tasks;
5
using Microsoft.AspNetCore.Hosting;
6
using Microsoft.Extensions.Configuration;
7
using Microsoft.Extensions.Hosting;
8
using Microsoft.Extensions.Logging;
9
10
namespace CK.Tutorial.GraphQlApi.Web
11
{
12
public class Program
13
{
14
public static void Main(string[] args)
15
{
16
CreateHostBuilder(args).Build().Run();
17
}
18
19
public static IHostBuilder CreateHostBuilder(string[] args) =>
20
Host.CreateDefaultBuilder(args)
21
.ConfigureWebHostDefaults(webBuilder =>
22
{
23
webBuilder.UseStartup<Startup>()
24
.ConfigureKestrel((context, options) =>
25
{
26
options.AllowSynchronousIO = true;
27
});
28
});
29
}
30
}
Copied!
Last modified 1yr ago
Copy link