Synchronous usage of middleware on ASP.NET Core 3.0 w/ Blazor
See original GitHub issueHi, I was testing new 3.0 bits and have been using this library for a long time to comply with SOAP requirements.
It throws InvalidOperationException: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.
In 3.0, AllowSynchronousIO is disabled by default. See: https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio#allowsynchronousio-disabled
Here is the stacktrace:
Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpResponseStream.Write(byte[] buffer, int offset, int count) System.Xml.XmlStreamNodeWriter.FlushBuffer() System.Xml.XmlStreamNodeWriter.GetBuffer(int count, out int offset) System.Xml.XmlStreamNodeWriter.UnsafeWriteUTF8Chars(Char* chars, int charCount) System.Xml.XmlUTF8NodeWriter.UnsafeWriteEscapedText(Char* chars, int count) System.Xml.XmlUTF8NodeWriter.WriteEscapedText(string s) System.Xml.XmlBaseWriter.WriteString(string value) System.Xml.XmlDictionaryAsyncCheckWriter.WriteString(string text) System.Xml.XmlWriter.WriteAttributeString(string localName, string value) SoapCore.MetaMessage.OnWriteStartEnvelope(XmlDictionaryWriter writer) System.ServiceModel.Channels.Message.WriteMessagePreamble(XmlDictionaryWriter writer) System.ServiceModel.Channels.Message.OnWriteMessageAsync(XmlDictionaryWriter writer) System.ServiceModel.Channels.Message.WriteMessageAsync(XmlDictionaryWriter writer) System.ServiceModel.Channels.TextMessageEncoderFactory+TextMessageEncoder.WriteMessageAsync(Message message, Stream stream) System.ServiceModel.Channels.TextMessageEncoderFactory+TextMessageEncoder.WriteMessageAsyncInternal(Message message, Stream stream) System.Runtime.TaskHelpers.WaitForCompletionNoSpin(Task task) System.ServiceModel.Channels.TextMessageEncoderFactory+TextMessageEncoder.WriteMessage(Message message, Stream stream) SoapCore.SoapEndpointMiddleware.ProcessMeta(HttpContext httpContext) SoapCore.SoapEndpointMiddleware.ProcessOperation(HttpContext httpContext, IServiceProvider serviceProvider) SoapCore.SoapEndpointMiddleware.Invoke(HttpContext httpContext, IServiceProvider serviceProvider) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
It would be better to use asynchronous APIs instead of synchronous ones. I would rather keep the default off as Microsoft recommends.
Microsoft’s recommended way to re-enable synchronous APIs is: in Program.cs configure Kestrel with the option.
Sorry for the delay, the latest version works fine. Thanks for the implementation. Closing this issue.