469,927 Members | 1,322 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

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 3000

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by genc_ ymeri at hotmail dot com | last post: by
reply views Thread by Kumar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.