0

I am very new in ASP.NET. I want help about how to get file from specific location and send to the client through action controller.

Shakir Ahmed
  • 559
  • 4
  • 13
  • Controllers can return `FileResult`, if you which the client to download a file, then check returning `FileResult` see [here](https://stackoverflow.com/questions/3604562/download-file-of-any-type-in-asp-net-mvc-using-fileresult) – Bosco Feb 22 '20 at 14:01

1 Answers1

0

To send any file to the client from the server I can use..............

        var fileBytes = System.IO.File.ReadAllBytes(inkFormulation.DocumentPath);
        var ext = ImageFormat.Jpeg;// the file extension you want to use 
        return base.File(fileBytes, $"image/{ext}", $"SampleImage.{ext}");

This is for image file. You can send any file with specific file extension.

Shakir Ahmed
  • 559
  • 4
  • 13