Help Plz in that e-mail client
-
hi, i have a problem regarding this piece of code it throw an exception ("time out expired ") can anyone tell me why
try { // Write the request Stream reqStream = webRequest.GetRequestStream(); reqStream.Write(requestBytes,0,requestBytes.Length); reqStream.Close(); // Get a response HttpWebResponse webResponse=(HttpWebResponse)webRequest.GetResponse(); if (webRequest.HaveResponse) { // Handle returned cookies foreach(Cookie retCookie in webResponse.Cookies) { bool cookieFound = false; foreach(Cookie oldCookie in ccContainer.GetCookies(destination)) { if (retCookie.Name.Equals(oldCookie.Name)) { oldCookie.Value = retCookie.Value; cookieFound = true; } } if (!cookieFound) ccContainer.Add(retCookie); } // Handle redirection headers if ((webResponse.StatusCode == HttpStatusCode.Found) || (webResponse.StatusCode == HttpStatusCode.Redirect) || (webResponse.StatusCode == HttpStatusCode.Moved) || (webResponse.StatusCode == HttpStatusCode.MovedPermanently)) { WebHeaderCollection headers = webResponse.Headers; return SendRequestTo(requestBytes,new Uri(headers["location"]),credential); } // Read response StreamReader stream = new StreamReader(webResponse.GetResponseStream()); string responseString = stream.ReadToEnd(); stream.Close(); return responseString; } // No response throw new ApplicationException("No response received from host."); } catch(WebException e) { // Error occured Trace.WriteLine("Exception occured " + e.Message); throw new ApplicationException("Exception occured while sending request.",e); }
-
hi, i have a problem regarding this piece of code it throw an exception ("time out expired ") can anyone tell me why
try { // Write the request Stream reqStream = webRequest.GetRequestStream(); reqStream.Write(requestBytes,0,requestBytes.Length); reqStream.Close(); // Get a response HttpWebResponse webResponse=(HttpWebResponse)webRequest.GetResponse(); if (webRequest.HaveResponse) { // Handle returned cookies foreach(Cookie retCookie in webResponse.Cookies) { bool cookieFound = false; foreach(Cookie oldCookie in ccContainer.GetCookies(destination)) { if (retCookie.Name.Equals(oldCookie.Name)) { oldCookie.Value = retCookie.Value; cookieFound = true; } } if (!cookieFound) ccContainer.Add(retCookie); } // Handle redirection headers if ((webResponse.StatusCode == HttpStatusCode.Found) || (webResponse.StatusCode == HttpStatusCode.Redirect) || (webResponse.StatusCode == HttpStatusCode.Moved) || (webResponse.StatusCode == HttpStatusCode.MovedPermanently)) { WebHeaderCollection headers = webResponse.Headers; return SendRequestTo(requestBytes,new Uri(headers["location"]),credential); } // Read response StreamReader stream = new StreamReader(webResponse.GetResponseStream()); string responseString = stream.ReadToEnd(); stream.Close(); return responseString; } // No response throw new ApplicationException("No response received from host."); } catch(WebException e) { // Error occured Trace.WriteLine("Exception occured " + e.Message); throw new ApplicationException("Exception occured while sending request.",e); }
If "time out expired" is the exception text, then that is the reason your code has a problem. Try changing "e.Message" to "e.ToString()" so you know which line had the problem (you might get a little bit more information, too). Some of the basic reasons for a timeout are that the server isn't up, you have a bad address, or your connection to the server has been interrupted somewhere along the way. John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.