Sunday, March 20, 2016

HttpWebRequest의 첫번째 동작이 느릴때. ( HttpWebRequest slow first time )

HttpWebRequest의 Proxy 설정을 null 로 해주면 해결된다.


 HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create( URL );
 httpRequest.Credentials = CredentialCache.DefaultCredentials;

 httpRequest.Proxy = null;

 httpRequest.Method = "GET";
 httpRequest.KeepAlive = false;

 HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse();
 System.IO.Stream dataStream = httpResponse.GetResponseStream();
 System.IO.StreamReader streamReader = new System.IO.StreamReader(dataStream);

 String responseText = streamReader.ReadToEnd();

 dataStream.Close();
 streamReader.Close();
 httpResponse.Close();


-------------------
problem : very slow response when first request.
solution : assign null to Proxy attribute.

No comments:

Post a Comment