A practical guide on how to serve PDF files in ASP.NET Core with two distinct behaviors: in-browser preview and forced download. The browser preview relies on the `application/pdf` MIME type, while the download behavior is triggered by setting the `Content-Disposition` response header to `attachment` with a filename. QuestPDF is recommended for generating the PDFs, and the approach works with MVC, Razor Pages, and Minimal APIs.

4m read timeFrom khalidabuhakmeh.com
Post cover image
Table of contents
Generating a PDF with QuestPDFPreviewing a PDF File in the BrowserDownloading a PDF File in the BrowserConclusion