title: System.Net.WebClient The underlying connection was closed
body: <blockquote>
    <p>The underlying connection was closed: The connection was closed unexpectedly</p>
  </blockquote>
  
  <p>I'm receiving the error message when using WebClient. I had tested this with asp code and it is running pretty well. But when I try to run the exe version of the code it running the following error, and I able to access the request address from the server, and it is within the internal network.</p>
  
  <p>My server setup :-
  Windows Server 2003 Entrerprise SP2
  asp.net 2.0.50727
  iis v6.0</p>
  
  <p>Here is some code:</p>
  
  <p>Manually accessing the </p>
  
  <pre><code>protected static String cross_server_req(String strContent, String strPage, String strPrivateKey)
      {
          try
          {
              WebClient wc = new WebClient();
              String strURL = SERVICE_PATH + strPage + "?r=" + DES_.DESEncrypt(strContent);
              byte[] responseArray = wc.DownloadData(strURL);
              String strResData = Encoding.UTF8.GetString(responseArray);
              if (Config.RecordWebService == "1")
              {
                  String strLogContent = "Request:" + strContent + "\r\nResponse:" + strResData + "\r\nDateCreated:" + D_Time.DNow + "\r\n\r\n";
                  ServiceLog.Logger(strPage, strLogContent);
              }
              if (null != strResData &amp;&amp; String.Empty != strResData)
              {
                  return strResData.Trim();
              }
          }
          catch (Exception ex)
          {
              ServiceLog.Logger("cross_server_req() Exception:" + ex.Message + "\r\n" + ex.StackTrace);
          }
          return null;
      }
  </code></pre>
  
  <p>Here is from log</p>
  
  <pre><code>cross_server_req() Exception:The underlying connection was closed: The connection was closed unexpectedly.
  at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest&amp; request)
  at System.Net.WebClient.DownloadData(Uri address)
  at System.Net.WebClient.DownloadData(String address)
  at Account.cross_server_request_curl(String strContent, String strPage, String strPrivateKey)
  </code></pre>
  
  <p>Please let me know any suggestion help this problem? I had look around the site and no solution had found.</p>