Aspnetcore: HttpResponseStreamWriter WriteLineAsync can cause exception

Created on 1 Nov 2019  ·  4Comments  ·  Source: dotnet/aspnetcore

Describe the bug

WriteLineAsync method of HttpResponseStreamWriter in Asp.Net Core 3.0 can cause the following exception:

InvalidOperationException when attempting to write to the response body – with a message “Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.”.

I think it occurs, because default implementation on TextWriter creates new Task which calls Write method. This method is overriden in HttpResponseStreamWriter and writes to response stream in synchronous way. I guess it is a bug.

I've found an issue #2895 says this one and other methods should be overriden. But as I see, it is delayed.

Expected behavior

To work without setting AllowSynchronousIO = true or using WriteAsync(line + "\n")

Duplicate area-servers bug

All 4 comments

@javiercn FYI HttpAbstractions issues are tracked in area-servers, not hosting.

That would be a good reason to fix #2895.

We have a similar issue for the reading side

Let's tackle all this together. Closing this as a dupe of #2895

Was this page helpful?
0 / 5 - 0 ratings

Related issues

UweKeim picture UweKeim  ·  3Comments

FourLeafClover picture FourLeafClover  ·  3Comments

Kevenvz picture Kevenvz  ·  3Comments

ipinak picture ipinak  ·  3Comments

fayezmm picture fayezmm  ·  3Comments