Reputation: 21
Currently I have an issue on an ASP.NET Web Form application, where some people are not able to get the fully downloaded file being requested.
The file does download fully sometimes, but other times it stays hanging after a certain amount of bytes, and eventually the browser seems to suggest a network error. Again I would like to emphasis sometimes it's fine, other times the download is just stuck and not responding. I have tried putting a try/catch but nothing is being returned.
I cannot replicate this on a test web server, it only happens on production which makes this issue more difficult to find.
It seems nothing passed the flush, statement is being executed when this happens. If it doesn't occur all is normal.
public void DownloadFile(byte[] fileImage, string fileName )
{
if (fileImage == null) return;
string fileExt = fileName.Substring(fileName.LastIndexOf('.') + 1);
string disposition = string.Format("attachment;filename=\"{0}\"", fileName);
Response.Clear();
Response.Buffer = true;
Response.ContentType = GetContentType(fileExt);
Response.ContentEncoding = System.Text.Encoding.Default;
Response.AddHeader("content-disposition", disposition);
Response.BinaryWrite(fileImage);
Response.Flush();
Response.End();
}
Upvotes: 1
Views: 1032
Reputation: 1
This could be from Network , try to open the app directly from the server and see if it happens again. you can also check the log for the requests that goes for server and see what http code they get after they deliver. those was my experience , hope it helps.
Upvotes: 0
Reputation: 21
So I found out the issue was caused by a Load balancer and not the code. The manner in which the load balancer was handling SSL seemed to be the key thing that caused this. For now the solution was to offload SSL Handling to the Web Server.
Upvotes: 1