MVC has a lot of great built in tooling, including the ability to stream very large file results straight from disk without having to load the whole file stream into memory.
What about the scenario where you want to stream a large file from one web server to another?
For example, I have an ASP.NET MVC application that needs to expose a download for a file hosted on another server, but I can not just redirect my users directly to the other URL. For that, we need to create a custom ActionResult type!
WebRequestFileResult
Here is a simple of example of what your controller might look like:
public class FileController : Controller
{
public ActionResult LocalFile()
{
return new FilePathResult(@"c:\files\otherfile.zip", "application/zip");
}
public ActionResult RemoteFile()
{
return new WebRequestFileResult("http://otherserver/otherfile.zip");
}
}