title: wrapping on using statement is throwing an error on api controller
body: <p>I have below lines of code on my API controller which will return the file. This lines code code is working fine but I wanted to wrap these into the using statement to avoid the memory leaks. But if I do that, endpoint is not returning the file and I am getting exception "An unhandled exception was thrown by the application. System.ObjectDisposedException: Cannot access a closed Stream." </p>
  
  <pre><code>                Stream memory = await _mySrv.GetDocMemoryStream(data);  
                  var contentType = filename.GetContentType();
                  return File(memory, contentType, "myfile.pdf");
  </code></pre>
  
  <p>Is it safe to leave the code like this, at least on the API controller? Will it handle by .NET core framework?</p>