Solved

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

Posted on 2004-03-25
8
7,296 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
Comment Utility
use
  Server.ScriptTimeout = <x> like Server.ScriptTimeout = 1000000 in the code behind file.

where x in second,
0
 
LVL 11

Author Comment

by:ajaikumarr
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 11

Accepted Solution

by:
ajaikumarr earned 0 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Hai Kapcreations,

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

Bye
Ajai
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now