How to properly dispose the stream when using StreamContent
<p>I'm attempting to return a stream from my webapi endpoint, and then clean up by disposing the stream.</p>

<p>I expected this to be the correct way, but the stream is of course disposed before returning.</p>

<pre><code>using(var stream = GetStream()){
    var response = new HttpResponseMessage();
    response.Content = new StreamContent(stream);

    return response;
}
</code></pre>

<p>What will be the correct way of disposing the stream?</p>

<p>(Since MSDN says nothing about the behaviour of StreamContent or its methods, my temporary solution is to copy the contents of the stream to a byte array and return that.)</p>