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.GetDownloadsArea() + 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("Content-Disposition",
                    "attachment; filename=" + file.Name);
                Response.AddHeader("Content-Length",
                    file.Length.ToString());
                Response.ContentType = "application/octet-stream";
                Response.WriteFile(filename);
                Response.End();

Anything wrong or suspicious about this code snippet? What other reasons could cause a file download problem?

Thanks..
LubomirMasarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Göran AnderssonCommented:
That code is not downloading anything. It's sending a file as response, it's the browser that's doing the downloading.

It's probably the request time-out that stops the code. Try to increase the time-out value:

Server.ScriptTimeout = 600; // ten minutes
0
LubomirMasarAuthor Commented:
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.
0
Göran AnderssonCommented:
The ASP ScriptTimeout was used by the classic ASP, but I am not certain that it's used by ASP.NET. Besides, you may have a different setting in web.config, which would override any setting in IIS. Specifying the timeout in the code will override any other setting.

A while back I built an application for a company that needed centralised uploading and downloading of large files (hundreds of megabytes), so I have experienced these limits myself. By default there is a 4 MB size limit on uploads, but there is no such size limit on downloads. The only limit for downloads is the script timeout.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LubomirMasarAuthor Commented:
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.
0
Göran AnderssonCommented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.