Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Help Plz in that e-mail client

Help Plz in that e-mail client

Scheduled Pinned Locked Moved C#
helpdebugging
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SherKar
    wrote on last edited by
    #1

    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); }

    J 1 Reply Last reply
    0
    • S SherKar

      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); }

      J Offline
      J Offline
      John Fisher
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups