473,385 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

System.Net.WebException: The operation has timed-out.

Hello All,
I am having a very strange problem.
while trying to access http page on the web using HTTPWebRequest Class,
I happen to have some problems at specific machines.
The exception I get is:
************* Exception Text **************
System.Net.WebException: The operation has timed-out.
at System.Net.HttpWebRequest.GetResponse()
at wwHTTP.SimpleHttpWebRequest.cmdGo_Click(Object sender, EventArgs
e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)
At most of the machines it works just fine.
By the way: THERE IS NO PROXY SERVER DEFINED.

thank you
yariv
The code is as follows:
private void cmdGo_Click(object sender, System.EventArgs e)
{
// *** Establish request by assigning Url
HttpWebRequest loHttp = (HttpWebRequest)
WebRequest.Create(this.txtUrl.Text.TrimEnd());
// *** Set any header related and operational
properties
loHttp.Timeout = 10000; // 10 secs
loHttp.UserAgent = "Code Sample Web Client";
// *** reuse cookies if available
loHttp.CookieContainer = new CookieContainer();

if (this.oCookies != null &&
this.oCookies.Count > 0)
{

loHttp.CookieContainer.Add(this.oCookies);
}
// *** Return the Response data
HttpWebResponse loWebResponse =
(HttpWebResponse)
loHttp.GetResponse();
// ** If the server returns any cookies
// ** add 'em to our cookies collection
if (loWebResponse.Cookies.Count > 0)
if (this.oCookies == null)
{
this.oCookies =
loWebResponse.Cookies;
}
else
{
// ** If we already have
cookies update the list
foreach (Cookie oRespCookie in
loWebResponse.Cookies)
{
bool bMatch = false;
foreach(Cookie
oReqCookie in this.oCookies)
{
if
(oReqCookie.Name == oRespCookie.Name)
{

oReqCookie.Value = oRespCookie.Name;
bMatch
= true;
break;
//
}
}
if (!bMatch)

this.oCookies.Add(oRespCookie);
}
}
Encoding enc = Encoding.GetEncoding(1252); //
Windows-1252 or iso-
if (loWebResponse.ContentEncoding.Length > 0)
{
enc =
Encoding.GetEncoding(loWebResponse.ContentEncoding );
}
StreamReader loResponseStream =
new
StreamReader(loWebResponse.GetResponseStream(),enc );
this.txtHTML.Text =
loResponseStream.ReadToEnd();
loResponseStream.Close();
loWebResponse.Close();
}
thank you,
yariv

Nov 17 '05 #1
0 3266

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jonathan Crowther | last post by:
On one PC the following test code results in an error on the GetResponse line while it works OK on another PC. The only difference that I am aware of is that the one that works is XP while the...
1
by: Sean Erwin | last post by:
I am having a very frustrating intermittent problem. I am making an A2A call to a remote server and when I issue the: WebRequest.getResponse call it occasionally fails with the following error: ...
2
by: genc_ ymeri at hotmail dot com | last post by:
Hi, I'm trying to recieve the response status code rather than the message in the below code : try { responseArray = myWebClient.UploadValues(uriString,"POST",myNameValueCollection); }...
0
by: Kumar | last post by:
Hi all, I have the following code which uses WebClient.UploadValues myNameValueCollection.Add("Name", name) myNameValueCollection.Add("Age", age) .............. ............. Dim web As New...
0
by: Faiyaz | last post by:
Hello to EveryBody i'm Getting this Peculiar error System.ApplicationException: The remote server returned an error (400) Bad Request. - - > System.Net.WebException: The remote server...
1
by: Tim Reynolds | last post by:
Team, From a windows service, we consume a web service on another server and occasionally receive System.Net.WebException: The underlying connection was closed:. For some clients we call, we do...
8
by: Tim Reynolds | last post by:
Our .Net application calls a web method of aplpication 2 that resides on their Apache server. When I as a developer C#, Studios 2003, make the call to their web method from my desktop, I receive no...
0
by: Seth Thibodeaux | last post by:
I have built a Windows Service that connects to Sql Server 2000 Reporting Services via its Web Service interface for the purpose of generating reports. Intermittently, calls made to the Web Service...
2
by: Scott McFadden | last post by:
When I invoke two web service methods sequentially with no delay, the first web method invocation goes smooth while the 2nd one generates the dredded: System.Net.WebException: The underlying...
3
sid0404
by: sid0404 | last post by:
Hi I am new to the programming in c#, I have an application where I need to get data from a website now I am getting an error message if I give the input as two strings, say Sun Microsystems while...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.