In this post we are going to see how to view or download PDF files in ASP.NET MVC, Normally in applications we have reports and files to be viewed in PDF format, sometimes we need to download the files, Now we are going to see various ways of viewing a PDF file and downloading option in MVC.
In ASP.NET MVC we have action result which is used to server the file content to the client browser, FilePathResult is used to display the content of the PDF file in the browser.
Steps to do:
1. Create a MVC Project
2. Create a Folder PdfFiles
3. Place your PDF files
4. Start writing your Controller logic.
Here for View , we will do three different ways one with passing File path, another one with passing File Content, another one is embedding as inline PDF using Ajax.
When you click the View button it will display the PDF file in the browser.
From this post you can learn how to create a application to View and Download PDF files in ASP.NET MVC