When running on IIS 7.5 on Server 2008 R2, I've been able to reproduce a deadlock when doing async writes on a chunked response.
For instance:
```
[HttpGet]
public HttpResponseMessage Test()
{
var resp = Request.CreateResponse();
resp.Content = new NeatoHttpContent();
return resp;
}
public class NeatoHttpContent : HttpContent
{
protected override async Task SerializeToStreamAsync(Stream stream, TransportContext context)
{
stream.Flush();
var foo = "1234567890";
var bytes = Encoding.ASCII.GetBytes(foo);
for (var i = 0; i < 70000; i++)
{
await stream.WriteAsync(bytes, 0, bytes.Length);
}
}
protected override bool TryComputeLength(out long length)
{
length = 0;
return false;
}
}
```
On the line with the WriteAsync, if I add a ConfigureAwait(false) afterwards, it gets rid of the deadlock. Unfortunately this isn't really practical from my production code since I'm returning an object result which is serializing JSON. Yes, I know I could write my own facade over the http content but that isn't terribly practical.
For instance:
```
[HttpGet]
public HttpResponseMessage Test()
{
var resp = Request.CreateResponse();
resp.Content = new NeatoHttpContent();
return resp;
}
public class NeatoHttpContent : HttpContent
{
protected override async Task SerializeToStreamAsync(Stream stream, TransportContext context)
{
stream.Flush();
var foo = "1234567890";
var bytes = Encoding.ASCII.GetBytes(foo);
for (var i = 0; i < 70000; i++)
{
await stream.WriteAsync(bytes, 0, bytes.Length);
}
}
protected override bool TryComputeLength(out long length)
{
length = 0;
return false;
}
}
```
On the line with the WriteAsync, if I add a ConfigureAwait(false) afterwards, it gets rid of the deadlock. Unfortunately this isn't really practical from my production code since I'm returning an object result which is serializing JSON. Yes, I know I could write my own facade over the http content but that isn't terribly practical.