0

I am currently building my project locally using MVC.

The user enters some search information and is presented with a link to download a file in Vox format that exists somewhere else on the network.

That other server has a shared drive with authentication.

I need to have my controller grab that file and spit it out to the client for download.

What is the best approach?

Thanks!

tereško
  • 58,060
  • 25
  • 98
  • 150
Har
  • 4,864
  • 2
  • 19
  • 22

1 Answers1

1

What is the best approach?

By exposing a controller action that returns a FileResult:

public ActionResult Download()
{
    byte[] file = ... go and fetch the file contents from wherever it is stored
    return File(file, "some MIME type", "filename.someextension");
}

and then inside your view provide a link to the user so that he can download:

@Html.ActionLink("download the Vox file", "Download")
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928