Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an MVC project where I'd like the user to be able to download a pdf file with a click of a button.
Posted

1 solution

Refer - How can I present a file for download from an MVC controller?[^].
Quote:
Return a FileResult or FileStreamResult from your action, depending on whether the file exists or you create it on the fly.
C#
public ActionResult GetPdf(string filename)
{
    return File(filename, "application/pdf", Server.UrlEncode(filename));
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900