Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.
Dung Do Tien
Nov 22 2020
618
I have a project written by Asp.net Core 2.2 and now I want to migrate to version 3.0 but after migrate done and run the application I got an error Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.
An unhandled exception has occurred while executing the request.
System.InvalidOperationException: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpResponseStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.Compression.DeflateStream.PurgeBuffers(Boolean disposing)
at System.IO.Compression.DeflateStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.IO.Stream.Dispose()
at System.IO.Compression.GZipStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.IO.Stream.Dispose()
at WebMarkupMin.AspNetCore2.BodyWrapperStreamBase.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.IO.Stream.Dispose()
at WebMarkupMin.AspNetCore2.BodyWrapperStreamWithBufferingFeature.FinishAsync()
at WebMarkupMin.AspNetCore2.WebMarkupMinMiddleware.ProcessAsync(HttpContext context, Boolean useMinification, Boolean useCompression)
at WebMarkupMin.AspNetCore2.WebMarkupMinMiddlewareBase.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Before that, It's still working fine in Asp.Net Core version 2.2.
Please suggest to me if you have any solution.
Have 1 answer(s) found.
-
M0
Marry Christ Nov 22 2020
You can resolve by way allow Synchronous IO in your application. You can do as below:
Inside method
ConfigureServices()
inStartUp.cs
you add more option below:- Option 1: If you run in the Kestrel server.
services.Configure<KestrelServerOptions>(options => { options.AllowSynchronousIO = true; });
- Option 2: If you run in the IIS server.
services.Configure<IISServerOptions>(options => { options.AllowSynchronousIO = true; });
* Type maximum 2000 characters.
* All comments have to wait approved before display.
* Please polite comment and respect questions and answers of others.