遇到异常:Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true ins...

对着背影说爱祢 提交于 2020-08-17 18:22:14
原文: 遇到异常:Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead

嗯,在使用 asp.net core 中遇到这么一个异常:

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

解决方法,加入配置:

复制代码
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;
    });
}
复制代码
转自: https://stackoverflow.com/questions/47735133/asp-net-core-synchronous-operations-are-disallowed-call-writeasync-or-set-all
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!