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;
    });
}

Comments


Comments are closed

About Us

Web/Mobile Solutions

Our Contacts

Cincinnati, OH 45069