WebRequest
을 작성하여 일부 HTML 컨텐츠를 다른 웹 서버에 게시하십시오. 일반 텍스트 콘텐츠를 사용하면 작동하지만, HTML 콘텐츠를 게시 할 때 GetResponse()
을 호출 할 때 시간 초과 오류가 발생합니다.GetResponse() 호출시 예외 시간 초과
WebResponse response = request.GetResponse()
어떻게 문제를 알 수 있습니까? WebException
에 대한 오류 처리기를 추가하려고 시도했지만 예외를 잡을 수 없습니다.
요청 코드 :
byte[] byteArray = Encoding.UTF8.GetBytes(sPostData);
// Create a request using a URL that can receive a post.
WebRequest request = WebRequest.Create(httpUri);
// Set the 'Timeout' property in Milliseconds.
//request.Timeout = 20000;
// Set the ContentType property of the WebRequest.
request.ContentType = contentType;
// Set the Method property of the request to POST.
request.Method = postMethod;
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
// Get the request stream.
using (Stream PostStream = request.GetRequestStream())
{
PostStream.Write(byteArray, 0, byteArray.Length);
}
// Get the response.
using (WebResponse response = request.GetResponse())
{
// Get the stream containing content returned by the server.
using (Stream responseStream = response.GetResponseStream())
{
using (StreamReader reader = new StreamReader(responseStream))
{
string responseFromServer = reader.ReadToEnd();
result = responseFromServer;
}
}
}
요청 코드도 표시 할 수 있습니까? – BrokenGlass
질문에 추가 된 요청 코드를 참조하십시오 – Roshe
어떤 아이디어라도 있으십니까? – Roshe