WebClient
우편 번호에서 전체 주소 세부 정보를 다운로드하는 데 사용하는 별도의 ASP 페이지를 시도하면 계속 오류가 발생 합니다.
The underlying connection was closed: An unexpected error occurred on a send.
이것은 서버에서만 발생합니다. 뿐만 아니라 URL을 브라우저에 붙여 넣으면 완벽하게 작동합니다. 방화벽 설정일 수 있습니까?
다음은 내가 사용중인 코드입니다 ( 여기의 다른 게시물에서 가져옴 ).
using (CookieAwareWebClient WC = new CookieAwareWebClient())
{
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3;
string data = WC.DownloadString("https://www.myUrl.com/postcode.asp?postcode=" + postcode + "&houseNumber=" + Server.HtmlEncode(txtHouseNumber.Text));
}
원래 나는 이것을 사용하여 같은 결과를 얻었습니다.
WebClient client = new WebClient();
string address = "https://www.myUrl.com/postcode.asp?postcode=" + postcode + "&houseNumber=" + Server.HtmlEncode(txtHouseNumber.Text);
string data = client.DownloadString(address);
이 응용 프로그램은 .NET 4 / C #으로 빌드되고 iis6이 설치된 Windows Server 2003에서 호스팅됩니다.
이것이 방화벽 또는 보안 설정이라면 무엇입니까? 그렇지 않은 경우 원인이나 해결 방법에 대한 생각이 있습니까? 많은 감사
업데이트-########################
좋아, HttpWebRequest도 시도했지만 두 번째 줄에서 오류가 발생합니다.
HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(new Uri("https://www.myUrl.com/postcode.asp?postcode=AZ11ZA&houseNumber=1"));
HttpWebResponse webresponse = (HttpWebResponse)webrequest.GetResponse();
오류 메시지에는 다음이 포함됩니다.
System.Threading.Thread.AbortInternal() at System.Threading.Thread.Abort(Object stateInfo) at System.Web.HttpResponse.End() at MyApp.MyPage.WebClientTest()
그것이 누구에게 도움이 될지 모르겠습니다 ...
질문의 댓글에있는 Jamby의 답변에서 발췌 :
https 대신 http로 액세스 해 보셨습니까?
단순한. 감사
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다