簡體   English   中英

F#:不允許同步操作。 調用 ReadAsync 或將 AllowSynchronousIO 設置為 true

[英]F# : Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead

在 Postman 中為以下存儲庫( https://github.com/websharper-samples/PeopleAPI )執行 POST 或 PUSH 請求時,

我收到此錯誤: 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. 錯誤截圖

如何在 f# 中將 AllowSynchronousIO 設置為 true 以執行 API 的 POST 或 PUSH 請求?

派對遲到了。 我對 Giraffe F# 有這個問題。 通過更改修復它

WebHostBuilder()
    .UseKestrel()
    .UseContentRoot(contentRoot)
    .UseIISIntegration()
    .UseWebRoot(webRoot)
    .ConfigureAppConfiguration(Action<WebHostBuilderContext, IConfigurationBuilder> configureAppConfiguration)
    .Configure(Action<IApplicationBuilder> configureApp)
    .ConfigureServices(configureServices)
    .ConfigureLogging(configureLogging)
    .Build()
    .Run()

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()

configKestrel function 看起來像:

let configKestrel (opts : KestrelServerOptions) =
    opts.AllowSynchronousIO <- true

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM