My backend controller returns a file of type xlsx to my front, this is the method that returns:
public FileResult ListarLivrosExcel()
{
// Gerando minha planilha e recebendo-a
using (ExcelPackage arquivoExcel = new BmpoDTO().Gerar())
{
var stream = new MemoryStream();
arquivoExcel.SaveAs(stream);
// Mais sobre contentType: http://stackoverflow.com/questions/8166205/mime-type-for-excel-xml-asp-net-3-5
string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
string fileName = "Livros.xlsx";
stream.Position = 0;
return File(stream, contentType, fileName);
}
}
Well, what I expected was that the browser would download the file in xlsx format, but it does not automatically download.
debugging I can see the return binaries:
IsitpossibletouseJStosavethesebinaries?orwouldyouforceabrowserdownloadinxlsxformat?
resultusingblob