title: c# httpwebrequest getResponse() freezes and hangs my program
body: <p>I was trying to use httpwebrequest to use a rest like service on a remote server and from the first execution itself, my code was hanging the program. Then I tried it as a console application to make sure it has nothing to do with the program itself but no luck!</p>
  
  <pre><code>        string credentialsJson = @"{""username"":""test"",
                                        ""password"":""test"" 
                                     }";
  
          int tmp = ServicePointManager.DefaultConnectionLimit;
          HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"https://qrua.com/qr/service" + @"/auth/login");
          request.Method = "POST";
          request.KeepAlive = true;
          request.Timeout = 50000 ;
          request.CookieContainer = new CookieContainer();
          request.ContentType = "application/json";
          try
          {
              StreamWriter writer = new StreamWriter(request.GetRequestStream());
              writer.Write(credentialsJson);
          }
          catch (Exception e)
          {
              Console.WriteLine("EXCEPTION:" + e.Message);
          }
  
          //WebResponse response = request.GetResponse();
          try
          {
              using (WebResponse response = (HttpWebResponse)request.GetResponse())
              {
                  Console.WriteLine("request:\n" + request.ToString() + "\nresponse:\n" + response.ContentLength);
                  response.Close();
              }
          }
          catch (Exception e)
          {
              Console.WriteLine("EXCEPTION: in sending http request:" + " \nError message:" + e.Message);
          }
  </code></pre>
  
  <p>Tried several things from different forums but it doesnt help. Even a simple console app with the above code hangs the console indefinitely! Any help would be great..</p>
  
  <p>Thanks</p>