4,817 questions
Open an web api generated file in new tab
Francisco Rubio Delgado
1
Reputation point
Hi all!
I coded a Web Api wich generates and returns a pdf file, in Blazor Server web app.
It works, I can write the controller url and the pdf file shows correcty.
But I want to open it when the user clics a button. I think it wouldn't be hard, but I can't manage it.
My Controller:
[HttpGet]
[Route("InformeClientes")]
public IActionResult ClientesReport()
{
DataTable dt = [function to generate report data]
var path = [path to the report definicion - rdlc]
[open report]
[fill report with data]
var result = localReport.Execute(RenderType.Pdf, 1, parameters, "");
return File(result.MainStream, System.Net.Mime.MediaTypeNames.Application.Octet, "Informe.pdf");
}
If I call it this way:
void Exportar()
{
var fichero = clienteHttp.GetAsync("api/Clientes/InformeClientes");
}
The variable get filled, and no erros occurs, so I think it works (and if I write the api url in the browser the pdf is shown) How can I show the file in new tab programmatically?
Thanks.
Developer technologies | ASP.NET | ASP.NET Core
Developer technologies | .NET | Blazor
1,673 questions
Sign in to answer