Home > Back-end >  .NET 6: synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true ins
.NET 6: synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true ins

Time:01-05

I have implemented a console application in .NET 6.0. I have already AllowSynchronousIO = true in startup but still getting the same error. Below is code that i have added in the startup class to allow synchronous to true.

    services.Configure<IISServerOptions>(options =>
    {
        options.AllowSynchronousIO = true;
    });

CodePudding user response:

In your CreateHostBuilder (Program.cs) add this

.ConfigureWebHostDefaults(builder =>
{
    builder.ConfigureKestrel(options =>
    {
        options.AllowSynchronousIO = true;
    });
    builder.UseStartup<Startup>();
}

Not sure how to do that with minimal API

  •  Tags:  
  • Related