Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.


Recently, I have been using Rider much more often and thought I would document recent issue (only noticed in Rider) not Visual Studio with IIS Express.

- April 22, 2020

Rest of the Story:

Using JetBrains Rider using IIS Express to run asp.net core 3.1 web application, my httpcontext was null and had issues getting request bodies etc.  The exception message was

Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.

I could run the application with Visual Studio 2019 without any issue (on IIS Express), definitely confusing.
The issue was related to the following..

https://github.com/dotnet/aspnetcore/issues/8302

https://github.com/dotnet/aspnetcore/issues/7644

The solution

public void ConfigureServices(IServiceCollection services)  
{  
    // If using Kestrel:  
    services.Configure<KestrelServerOptions>(options =>  
    {  
        options.AllowSynchronousIO = true;  
    });  
  
    // If using IIS:  
    services.Configure<IISServerOptions>(options =>  
    {  
        options.AllowSynchronousIO = true;  
    });  
}