Search code examples
asp.net-corepdf-viewer

Error While trying to view PDF document in browser it just get downloaded [ASP.net Core 3.0]


I have tried to view pdf documents in my ASP.net core application but when I clicked on Read button the pdf document just get downloaded Here is My Code In my Home Controller I have GetPdf Action

  public ActionResult GetPdf(string fileName)
        {
            string filePath = "~/file/" + fileName;
            Response.Headers.Add("Content-Disposition", "inline; filename=" + fileName);
            return File(filePath, "application/pdf");
        }

and in the View part I have used

 <a href="/Home/GetPdf/php.pdf" class="btn btn-default">Read</a>

Solution

  • Turn off any download manager software installed on your system. When you try to read the pdf the download manager will take it over to download it.