-
Notifications
You must be signed in to change notification settings - Fork 473
Description
some OData batch requests result into internal error since synchronous calls are are not allowd in .net core 3.1
Assemblies affected
Microsoft.AspNetCore.OData (7.3.0)
.net core 3.1
Reproduce steps
call OData batch request with JSON body/response e.g.
{
"requests": [
{
"Id": "1",
"method": "DELETE",
"headers": {
"odata-version": "4.01",
"content-type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false"
},
"url": "Entity(6)",
"body": ""
}
]
}where the entity does'nt exists and the controller is returning NotFound()
Expected result
with the the workarround (disable check) I get the expected result, without this setting I get an internal error
webBuilder.ConfigureKestrel(options =>
{
options.AllowSynchronousIO = true;
});
Actual result
Internal error
Additional detail
System.InvalidOperationException: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpResponseStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at Microsoft.OData.JsonLight.ODataJsonLightBatchWriter.FlushSynchronously()
at Microsoft.OData.ODataBatchWriter.Flush()
at Microsoft.OData.ODataBatchWriter.WriteEndBatch()
at Microsoft.AspNet.OData.Batch.ODataBatchContent.WriteToResponseMessageAsync(IODataResponseMessage responseMessage)
at Microsoft.AspNet.OData.Batch.DefaultODataBatchHandler.ProcessBatchAsync(HttpContext context, RequestDelegate nextHandler)
at Microsoft.AspNet.OData.Batch.ODataBatchMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)