0

I have this controller method and it's work well , but it show the file in browser and i want to force download not show it , so what to change ?

public ActionResult DownloadFile(int id, string Url)
    {
        var b = db.Books.FirstOrDefault(s => s.Book_id == id);
        WebClient client = new WebClient();
        var fileStream = client.OpenRead(b.pdf_file);
        return new FileStreamResult(fileStream, "application/pdf");
    }
Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120

1 Answers1

0

Change it to:

return File(fileStream, "application/pdf", "MyRenamedFile.pdf");