I've been working to do a PDF
file download from bytes[]
in ASP.Net MVC C#. The below code is working fine.
I need to convert the code to .NET Core
for the same PDF
download process.
string fileName = "testFile.pdf";
byte[] pdfasBytes = Encoding.ASCII.GetBytes(fileBytes); // Here the fileBytes are already encoded (Encrypt) value. Just convert from string to byte
Response.Clear();
MemoryStream ms = new MemoryStream(pdfasBytes);
Response.ContentType = "application/pdf";
Response.Headers.Add("content-disposition", "attachment;filename=" + fileName);
Response.Buffer = true;
ms.WriteTo(Response.OutputStream);
Response.Flush();
Response.End();
I'm tried to convert the above code to .NET Core
. I get an error: OutputStream method doesn't contain Response for this ms.WriteTo(Response.OutputStream) line.
Thanks In advance.!