을 폐쇄되었다 System.Net.WebClient : 연결이 웹 클라이언트를 사용할 때 오류 메시지를 수신하고있어는 기본 연결이
예기치 않게 종료되었습니다. 나는 asp 코드로 이것을 테스트했고 꽤 잘 돌아가고있다. 하지만 다음 exe 버전의 코드를 실행하려고하면 다음 오류가 발생하며 서버에서 요청 주소에 액세스 할 수 있으며 내부 네트워크 내에 있습니다.
내 서버 설정 : - 윈도우 서버 2003 Entrerprise SP2 asp.net 2.0.50727 IIS 6.0 여기
몇 가지 코드 :
수동으로
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 && String.Empty != strResData)
{
return strResData.Trim();
}
}
catch (Exception ex)
{
ServiceLog.Logger("cross_server_req() Exception:" + ex.Message + "\r\n" + ex.StackTrace);
}
return null;
}
접근 다음은 로그에서입니다.
cross_server_req() Exception:The underlying connection was closed: The connection was closed unexpectedly.
at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& 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)
이 문제를 해결하는 데 도움이되는 제안 사항이 있으면 알려주십시오. 사이트 주변을 둘러 보았고 아무런 해결책도 발견되지 않았습니다.
wcf 서비스를 사용 하시겠습니까? –
wcf 서비스를 사용하고 있지 않습니다. – Gary