Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2004-03-25
8
7,455 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Suggested Solutions

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

839 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