While executing the POST or PUSH requests in Postman for the following repository ( https://github.com/websharper-samples/PeopleAPI ),
I am getting this error: System.InvalidOperationException: Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.
System.InvalidOperationException: Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.
Error Screenshot
How do I set AllowSynchronousIO to true in f# to execute POST or PUSH requests for an API?
Extremely late to the party. I had this problem with Giraffe F#. Fixed it by changing
WebHostBuilder()
.UseKestrel()
.UseContentRoot(contentRoot)
.UseIISIntegration()
.UseWebRoot(webRoot)
.ConfigureAppConfiguration(Action<WebHostBuilderContext, IConfigurationBuilder> configureAppConfiguration)
.Configure(Action<IApplicationBuilder> configureApp)
.ConfigureServices(configureServices)
.ConfigureLogging(configureLogging)
.Build()
.Run()
to
WebHostBuilder()
.UseKestrel(Action<KestrelServerOptions> configKestrel)
.UseContentRoot(contentRoot)
.UseIISIntegration()
.UseWebRoot(webRoot)
.ConfigureAppConfiguration(Action<WebHostBuilderContext, IConfigurationBuilder> configureAppConfiguration)
.Configure(Action<IApplicationBuilder> configureApp)
.ConfigureServices(configureServices)
.ConfigureLogging(configureLogging)
.Build()
.Run()
and the configKestrel
function looks like:
let configKestrel (opts : KestrelServerOptions) =
opts.AllowSynchronousIO <- true
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.