Hi, @mc ,
In your Web Api
, I suggest you to return a base64 of type string instead of File
or FileStream
:
[HttpPost]
public string Post(int id)
{
//....other code.....
string fileName = @"C:\Users\Admin\xxxxxx\Test.pdf";
byte[] pdfByteArray = System.IO.File.ReadAllBytes(fileName);
string base64EncodedPDF = System.Convert.ToBase64String(pdfByteArray);
return base64EncodedPDF;
}
Then in ajax success function, you can use this code:
Demo:
------------------------------------------------------------------------------------------------
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Xinran Shen