np.
np.

Reputation: 2379

The operation has timed out

We shave this code which result in timeout when downlaoding the file programatically:

System.Net.WebClient Client = new System.Net.WebClient();
if (!File.Exists(fileName))
{
    Client.DownloadFile(downloadLink, fileName);
    HtFilesSuccessfullyDownloaded[fileName] = fileName;
    string SuccessfullyDownloadedFiles = Path.Combine(dirName, "SuccessfullyDownloadedFiles.txt");
    File.AppendAllText(SuccessfullyDownloadedFiles, Environment.NewLine + fileName);
}

It looks like when the files are large we are getting the timeout error when DownloadFile method is called. We have added the followign in web.config but it does not look like it helps:

 <httpRuntime maxRequestLength="1048576" executionTimeout="3600"
/>

Please let me know if you have any suggestions.

Upvotes: 0

Views: 3245

Answers (2)

Cj Anderson
Cj Anderson

Reputation: 851

Have you tried using Fiddler to see what is exactly happening? It might provide you with some more clues. Frankly it could even be a problem with the Webserver, and not your code. Also HTTPWebrequest has a timeout that you can set. You could try that instead.

Fiddler
HttpWebrequest

Upvotes: 1

Shoban
Shoban

Reputation: 23016

You are downloading the file to your server and the web.config entry is applicable for the files uploaded from a client.

Check this question for the answer you need

Set timeout for webClient.DownloadFile()

Out of curiosity...What will you be showing the user when the download is in progress?

Upvotes: 0

Related Questions