0

Scenario, I have a webpage, when a user open it they fill out a form and can download a T&C pdf file.

How to do this?

This is my controller code:

   public FileResult DownloadFile()
    {
       
        byte[] fileBytes = System.IO.File.ReadAllBytes(@"\\server\wwwroot\testapp\Files\Terms and Conditions.pdf");
        string fileName = "Terms and Conditions.pdf";
        return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
    }

What do I do on the Index (.cshtml) page for a download link?

fl13
  • 57
  • 1
  • 1
  • 12
  • Does this answer your question? [How to return a file (FileContentResult) in ASP.NET WebAPI](https://stackoverflow.com/questions/26038856/how-to-return-a-file-filecontentresult-in-asp-net-webapi) – JHBonarius Jan 25 '22 at 08:42
  • This is the answer. Just what I wanted. Can you answer so that I can mark it? @MashedSpud – fl13 Jan 25 '22 at 08:57

1 Answers1

1

Does the "Terms and Conditions.pdf" file change in anyway based on the data captured when the user completes the form? If not, could you not simply use an <a href="https://example.com/testapp/Terms%20and%20Conditions.pdf">Terms and Conditions</a> link?

Mashed Spud
  • 452
  • 4
  • 12