?
Solved

File Download ends incomplete..500 points..

Posted on 2008-02-06
5
Medium Priority
?
1,015 Views
Last Modified: 2012-08-13
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..
0
Comment
Question by:LubomirMasar
  • 3
  • 2
5 Comments
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20837159
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
 

Author Comment

by:LubomirMasar
ID: 20842685
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
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 1500 total points
ID: 20844290
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
 

Author Comment

by:LubomirMasar
ID: 20845584
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
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20845921
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

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Suggested Courses

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question