title: when recieving a file as a FileContentResult through an ajax post request, the byte array seems to get corrupted when passed into the response
body: <p>I'm using ajax to generate and view a File.</p>
  <pre><code>$.ajax({
      url: '/Materials/Enquiries/GetRequisitionVersion',
      type: 'POST',
      data: $('#materialRequisitionVersionForm').serializeArray()
  }).done(function (response) {
      var file = new Blob([response], { type: 'application/pdf' });
      var fileURL = URL.createObjectURL(file);
      window.open(fileURL);
  
  }).fail(function () {
  
  })
  </code></pre>
  <p>This is my controller method. The GenerateMaterialRequisitionPreview function returns a byte Array. To test I created a filestream to save the file locally.</p>
  <pre><code>public async Task&lt;IActionResult&gt; GetRequisitionVersion(Guid requisitionId)
      {
          var bytes = await _reportingClient.GenerateMaterialRequisitionPreview(requisitionId);
          
          //For testing
          using (FileStream pdfOutput = new FileStream(&quot;test2.pdf&quot;, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
          {
              pdfOutput.Write(bytes);
          }
              return File(bytes, &quot;application/pdf&quot;, &quot;generated.pdf&quot;);
      }
  </code></pre>
  <p>In the ajax response, when the new window opens, it returns an empty PDF file , however when i check the file saved by the filestream it's correct.
  <a href="https://i.stack.imgur.com/Kr3d5.png" rel="nofollow noreferrer">generated.pdf</a> <a href="https://i.stack.imgur.com/5dQ2w.png" rel="nofollow noreferrer">test2.pdf</a></p>
  <p>I inspected both pdf arrays and found that some of the characters in the generated pdf have been replaced by unknown characters □ and �
  If you compare these two images you'll see what i mean.
  <a href="https://i.stack.imgur.com/AkrUP.png" rel="nofollow noreferrer">corruptedPDF</a>
  <a href="https://i.stack.imgur.com/u7GCk.png" rel="nofollow noreferrer">correctPDF</a></p>
  <p>I'm not exaclty sure why the file is being corrupted this way and a fix for this. I am using google chrome.</p>