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
Can you please try the following code and see if that works?
public FileStreamResult Index()
{
HttpContext.Response.AddHeader("test", "val");
var file = System.IO.File.Open(Server.MapPath("~/Web.config"), FileMode.Open);
HttpContext.Response.AddHeader("Content-Length", file.Length.ToString());
return File(file, "text", "Web.config");
}
"It works on my machine"
And I've tried without the Content-length header and Fiddler reports a content length header anyway. I don't think it's needed.