1
I am testing the code below, but there is no action when I click button to open a PDF in new tab.
You’re missing something below?
Test.aspx
Clique <asp:LinkButton OnClick="linkPDF_click" ID="linkPDF" runat="server">aqui</asp:LinkButton> para abrir seu PDF.
Teste.aspx.Cs
protected void linkPDF_click(object sender, EventArgs e)
{
string FilePath = Server.MapPath("~/MediaFiles/Comuns/PDF/Arquivo Fatura.pdf");
WebClient User = new WebClient();
Byte[] FileBuffer = User.DownloadData(FilePath);
if(FileBuffer != null)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", FileBuffer.Length.ToString());
Response.BinaryWrite(FileBuffer);
}
}
but what the request returns, gives some error?
– Lucas Miranda