How to create save file dialog in MVC application? I couldn't find any example.
Thanks in advance.
By using the Content-Disposition
header to attachment when returning the file to download:
public ActionResult Download()
{
return File(@"c:\work\report.pdf", "application/pdf", "reoprt.pdf");
}
Or if the file to download is dynamically generated:
public ActionResult Download()
{
byte[] pdf = ... get the contents of the report
return File(pdf, "application/pdf", "reoprt.pdf");
}