My controller returns two file types: pdf and excel.
return File(stream, "application/pdf");
return File(new MemoryStream(ep.GetAsByteArray()), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $"Relatorio.xlsx");
When the request can be made by get, I do it as follows:
window.open(urlComParametros, "_blank");
In this way a new tab is opened, if the file type is pdf it opens for viewing, and if the type is excel the file is downloaded.
But now I need to make the requisition per post. I already have, converting the file to byte [] and then converting to Base64String. So, in the success of my request I do the following to open the files:
window.open("data:application/pdf;base64," + data, "_blank");
window.open("data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64," + data, "_blank");
That way it works, but there are some issues:
- I could not change the tab title
- I could not change the name of the excel file that is downloaded
- Does not work in IE
How can I solve these problems? Or is there any better way to return these files?