asp.Netcore 3.1中Synchronous operations are disallowed.Call FlushAsync or set AllowSynchronousIO to true instead
2352 ワード
アクションでの解決策:
次のようにすることもできます.
次のこともできます.
var syncIOFeature = HttpContext.Features.Get();
if (syncIOFeature != null)
{
syncIOFeature.AllowSynchronousIO = true;
}
次のようにすることもできます.
public void ConfigureServices(IServiceCollection services)
{
// If using Kestrel:
services.Configure(options =>
{
options.AllowSynchronousIO = true;
});
// If using IIS:
services.Configure(options =>
{
options.AllowSynchronousIO = true;
});
//..................
}
次のこともできます.
Request.EnableBuffering();
using (var reader = new StreamReader(Request.Body, encoding: Encoding.UTF8))
{
var body = reader.ReadToEndAsync();
// Do some processing with body…
// Reset the request body stream position so the next middleware can read it
Request.Body.Position = 0;
}