This is my code:
var net = new System.Net.WebClient();
var data = net.DownloadData(zipPath);
var content = new MemoryStream(data);
var contentType = "APPLICATION/octet-stream";
var fileName = zipPath.Split('\\')[zipPath.Split('\\').Length -1];
Response.Cookies.Append("download", "finished");
return File(content, contentType, fileName);
However, DownloadData(zipPath) gives error as WebException: "The message length limit was exceeded" it seems like it can't read more than 2GB of size, I searched and it needs to edit some property to -1 of an object which i didn't use in my code.. https://social.msdn.microsoft.com/Forums/en-US/88d0c0bb-ec86-435d-9d2a-c5ec821e9a79/httpwebresponse-maximum-response-header-size-response-over-64k-problem?forum=winappswithcsharp
and I have tried this aswell:
HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
var stream = new FileStream(zipPath, FileMode.Open, FileAccess.Read);
result.Content = new StreamContent(stream);
result.Content.Headers.ContentType =
new MediaTypeHeaderValue("application/octet-stream");
Gave this exception: System.IO.IOException: 'The file is too long. This operation is currently limited to supporting files less than 2 gigabytes in size.'
I don't know what to do anymore.. any advice? In the end i'm trying to return File(byte[]) so I could download that file from the server.