I have the following code I wrote in Asp.NET and I am trying to convert it to MVC, but not sure how I do this within an Action
HttpContext context;
context.Response.ContentType = "application/pdf";
context.Response.AppendHeader("Content-Disposition", String.Format("attachment;filename={0}", filename));
context.Response.WriteFile(filename);
context.Response.Flush();
context.Response.SuppressContent = true;
UPDATE:
So you have a server side script (
PDF.axd) which generates the PDF file. You don’t have the pdf file stored on your file system. In this case you will need to first fetch the pdf and then stream it to the client:The usefulness of this controller action is doubtful as you already have a script that does the job.