For a PDF file to be returned as an action response in MVC 2, we have two options:
1) Either;
public ActionResult GetMyPdfAsFile()
{
return File(Url.Content("~/Content/Files/PDFs/MyPdf.pdf" ), "application/pdf" );
}
2) or;
public FileStreamResult ShowMyPdf()
{
string filePath = Server.MapPath("/Content/Files/PDFs/MyPdf.pdf" );
byte [] pdf = System.IO.File .ReadAllBytes(filePath);
MemoryStream stream = new MemoryStream (pdf, 0, pdf.Length);
return new FileStreamResult (stream, "application/pdf" );
}