The operation has timed out HttpWebRequest.GetResponse(); RRS feed

  • General discussion

  • We are using the following code to call rest webservice

    And getting response when running windows 7 with .Net Framework 4.0

    But the code is giving "The operation has timed out" Exception while running Windows server 2008 r2 servicepack1 ,.Net Framework 4.0

    Kindly help us to fix this issue

    var loginReq = (HttpWebRequest)WebRequest.Create(URI);
    loginReq.ContentType = "application/json";
    loginReq.Method = "POST";
    loginReq.CookieContainer = cookieJar;
     using (var res = (HttpWebResponse)loginReq.GetResponse())


     catch (Exception ex)

    • Changed type senthil vibgyor Wednesday, August 6, 2014 6:02 AM Not able to figure out the problem
    Tuesday, August 5, 2014 1:37 PM

All replies

  • If you get a timeout exception then that probably means that the service takes a long time to respond. If such a long time is expected then you can try to increase the timeout by setting the Timeout property of the request to an appropriate value.

    The it's already 100 seconds so you may want to investigate why does the service takes so long to respond. Perhaps you use the wrong url, perhaps you're not sending some required data.

    Wednesday, August 6, 2014 5:06 AM
  • But how the same code and same request is working perfectly in windows 7
    Wednesday, August 6, 2014 6:04 AM
  • I see, so the service is known to work fine. Then maybe the Win2008 machine has a firewall or some network problems.

    Have you tried to use the service URL in a browser to see what happens?

    Wednesday, August 6, 2014 6:12 AM
  • Responses are

    404 error in windows server 2008 machine ,

    Blank page in windows 7 machine

    Wednesday, August 6, 2014 6:55 AM
  • The blank page is likely normal, the service probably expects a POST, not a GET.

    The 404 error would indicate that something is wrong with the url, service, network etc. Whatever is wrong is probably not related to the HttpWebRequest class so it's unlikely that I can help you further.

    Wednesday, August 6, 2014 7:09 AM
  • The blank page is coming  when i checking with firefox

    But the code is giving same time out exception

    http://url is giving response https://url is not
    Wednesday, August 6, 2014 10:39 AM