Display (Open) PDF File in new Window using C# in ASP.Net

on Aug 25, 2021 08:49 AM

I have below code. How do I open the pdf file in new window?

Please help. TQ in advance.

// utk file di server
string filePath = Server.MapPath("~/isoChecklist/" + (sender as ImageButton).CommandArgument); 
FileInfo file = new FileInfo(filePath); 
// Checking if file exists
if (file.Exists)
    // Clear the content of the response
    // LINE1: Add the file name and attachment, which will force the open/cance/save dialog to show, to the header
    Response.AddHeader("Content-Disposition", "inline; filename=" + file.Name); 
    // Add the file size into the response header
    Response.AddHeader("Content-Length", file.Length.ToString()); 
    // Set the ContentType
    Response.ContentType = ReturnExtension(file.Extension.ToLower());      


Download FREE API for Word, Excel and PDF in ASP.Net: Download
on Aug 25, 2021 08:49 AM
Hi @Hazel,
Please try the following

Open PDF File in New Window or New Tab on Button click in ASP.Net

It might help you.

Cheers Andrea.