Solved

How to resolve timeout problem on Net.WebClient.UploadData?

Posted on 2004-03-25
8
7,416 Views
Last Modified: 2007-11-27
Hai all,

I have a program which uploads 100k to 100mb files... It's working fine if the connection is LAN or > 56kbps line. When i try to upload 180k file using 36Kbps Dialup modem it fails to upload and says "time-out"... I searched on net for solution but no joys... I've seen a comment that this in ongoing problem right from VB6... Can somebody suggest me some way of overcome this problem... The code is running on VB.NET using the namespace Net.WebClient.UploadData. I've tried Net.WebClient.Uploadfile "PUT" method, but the files are getting corrupted on remote server as PUT method has some restrictions on upload size... I've tried "POST" method too but unfortunately my server does not support this method....

I'm trying HttpWebRequest to upload files... I'm not sure that this might solve my problems.... does any body having experience using HttpWebRequest to upload min of 20mb file using dialup connection?

PS :- My remote system is running 2000 server with IIS (does'nt have .NET in it).

Any code sample would help to move forward.
Thanks in advance.
Ajai Kumar .R
0
Comment
Question by:ajaikumarr
  • 3
  • 2
8 Comments
 
LVL 6

Expert Comment

by:dash420
ID: 10676157
use
  Server.ScriptTimeout = <x> like Server.ScriptTimeout = 1000000 in the code behind file.

where x in second,
0
 
LVL 11

Author Comment

by:ajaikumarr
ID: 10685289
Hai Dash420,

>>The code is running on VB.NET using the namespace Net.WebClient.UploadData.<<
I'm writing it on VB.NET.

>>PS :- My remote system is running 2000 server with IIS (does'nt have .NET in it).<<
I dont have .NET installed on my server. so i can't use codebehind or server.scripttimeout....

Bye
Ajai
0
 
LVL 6

Expert Comment

by:dash420
ID: 10685351
Ok,
Open inetmgr, right click on the vertual folder. Click on directory tab. Then click on the configuartion button. Then click on the App Options. You find Asp Script time out in second. default is 90 sec. Increase it to required second.


0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 11

Accepted Solution

by:
ajaikumarr earned 0 total points
ID: 10711935
Hai dash420,

I've solved my problem using the below code... Any how thanks.

Dim UploadRequest As System.Net.HttpWebRequest = CType(System.Net.WebRequest.Create(New Uri(TargetFile)), System.Net.HttpWebRequest)
UploadRequest.Timeout = nnnnnn (Required timeout milliseconds)
UploadRequest.Method = "PUT"
UploadRequest.ContentLength = New System.IO.FileInfo(SourceFile).Length

Dim SourceStream As New System.IO.FileStream(SourceFile, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite)
Dim RequestStream As System.IO.Stream = UploadRequest.GetRequestStream()
Dim Buffer(4095) As Byte
Dim Position As Integer = 0, ivlLoop As Integer = 0
Position = SourceStream.Read(Buffer, 0, Buffer.Length)
While Position <> 0
  RequestStream.Write(Buffer, 0, Position)
  Position = SourceStream.Read(Buffer, 0, Buffer.Length)
End While

Dim WebResponse As System.Net.HttpWebResponse = CType(UploadRequest.GetResponse(), System.Net.HttpWebResponse)
Dim ResponseReader As New System.IO.StreamReader(WebResponse.GetResponseStream())
Response = ResponseReader.ReadToEnd()

RequestStream.Close()
UploadRequest = Nothing

Bye
Ajai Kumar .R
0
 
LVL 1

Expert Comment

by:kapcreations
ID: 11008930
ajaikumarr,

can you post the completed working code both for this application, as well as the receiving .aspx page?  I have a similar problem as can not seem to get past it.

TIA

kap
0
 
LVL 11

Author Comment

by:ajaikumarr
ID: 11020448
Hai Kapcreations,

I did this on VB.NET... If you think it would help you i can post it...

Bye
Ajai
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 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