LubomirMasar
asked on
File Download ends incomplete..500 points..
I have a ASP .NET web page which downloads files..It is working perfectly for small & average sized files..But when I download a large file (17MB file for instance) it starts the download well, but after 2 minutes or so (after downloading about 6MB) it just finishes. The downloaded file is incomplete. Why is this happening and how can I troubleshoot this?
My download code is given below.
FileInfo file = null;
string filename = null;
// get the fully qualified name of the selected file
filename = utils.Utils.GetDownloadsAr ea() + m_filename;
// get the file data since the length is required for the download
file = new FileInfo(filename);
// write it to the browser
Response.Clear();
Response.AddHeader("Conten t-Disposit ion",
"attachment; filename=" + file.Name);
Response.AddHeader("Conten t-Length",
file.Length.ToString());
Response.ContentType = "application/octet-stream" ;
Response.WriteFile(filenam e);
Response.End();
Anything wrong or suspicious about this code snippet? What other reasons could cause a file download problem?
Thanks..
My download code is given below.
FileInfo file = null;
string filename = null;
// get the fully qualified name of the selected file
filename = utils.Utils.GetDownloadsAr
// get the file data since the length is required for the download
file = new FileInfo(filename);
// write it to the browser
Response.Clear();
Response.AddHeader("Conten
"attachment; filename=" + file.Name);
Response.AddHeader("Conten
file.Length.ToString());
Response.ContentType = "application/octet-stream"
Response.WriteFile(filenam
Response.End();
Anything wrong or suspicious about this code snippet? What other reasons could cause a file download problem?
Thanks..
ASKER
GreenGhost,
That is unlikely..I have set the ASPScriptTimeout of the site at a high value (like 54000 seconds) from the IIS admin tool. Is the Server.ScriptTimeout a different property than that? The website ConnectionTimeout is also high at 1800 secs.
That is unlikely..I have set the ASPScriptTimeout of the site at a high value (like 54000 seconds) from the IIS admin tool. Is the Server.ScriptTimeout a different property than that? The website ConnectionTimeout is also high at 1800 secs.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
In any case, I put the Server.ScriptTimeout = 54000 in code prior to download..Made no difference whatsoever..The download is ending exactly after 90 secs. I dont know why it is so.
90 seconds is the default value for the timeout, which suggests that your attemt to change it failed.
Instead of a timeout of 15 hours, try a more reasonable value, like 15 minutes.
Check if there is a setting for executionTimeout attribute in the httpRuntime element in web.config.
Instead of a timeout of 15 hours, try a more reasonable value, like 15 minutes.
Check if there is a setting for executionTimeout attribute in the httpRuntime element in web.config.
It's probably the request time-out that stops the code. Try to increase the time-out value:
Server.ScriptTimeout = 600; // ten minutes