I have a download link in my page, to a file I generate by the user request. Now I want to display the file size, so the browser can display how much is left to download. As
This should solve it as I think there's no need to use the FileStreamResult, when you can use the byte[] directly.
public FileContentResult DownloadSignalRecord(long id, long powerPlantID, long generatingUnitID)
{
SignalRepository sr = new SignalRepository();
var file = sr.GetRecordFile(powerPlantID, generatingUnitID, id);
HttpContext.Response.AddHeader("Content-Length", file.Length.ToString());
return File(file, "binary/RFX", sr.GetRecordName(powerPlantID, generatingUnitID, id) + ".rfx");
}
Note the FileContentResult return type.