title: ASP.Net Core returns a 500 INTERNAL SERVER ERROR from a FileStreamResult
body: <p>ASP.Net Core returns a 500 server error from a FileStreamResult when using MemoryStream to write into PDF</p>
  <pre>public async Task &lt;Stream&gt; DownloadDocumentInfoAsPdfAsync(User loggedInUser) {
      try {
          var conversionOptions = new ConversionOptions {
              Margins = new MarginSettings(20, 5.5, 10, 5.5),
          };
  
          //Creating new MemoryStream from byte[]
          return new MemoryStream(_htmlToPdfConverter.ConvertHtml(html, conversionOptions));
      }
  }
  
  //Returning FileStream from above function.
  public async Task &lt;IActionResult&gt; GenerateReport([FromRoute] string info) {
      var result = await _mediator.Send(query);
      return File(result, &quot;application/pdf&quot;, &quot;employee.pdf&quot;); //This will through 500 INTERNAL SERVER ERROR
  }
  </pre>