I've got a problem. I have two completely separate websites, one written in .Net using MVC2, the other written in PHP.
I have links in my MVC site to media files in my PHP site, and I'm trying to find a way to force a download when the user clicks these links.
How could I do this in MVC? I understand how I can return a FileResult like this:
public FileResult Download(string path)
{
var contentType = "audio/mp3";
FilePathResult result = new FilePathResult(Server.MapPath("~/Content/"
+ path), contentType);
result.FileDownloadName = path;
return result;
}
But the Server.MapPath requires that the files be hosted on the MVC server.
Addendum
I also tried doing this on the .php side of the house, using a download.php?file=filepath and setting the content headers that way. However, I kept getting "Cannot modify header information - headers already sent" errors. I created a separate question on SO asking why this is happening.