C# first time I use GetRequestStream() it takes 20 seconds
<p>I use C#.</p>

<p>The first time I use WebRequest GetRequestStream() in my code, it takes up to 20 seconds. After that it takes it takes under 1 second.</p>

<p>Below is my code. The row "this.requestStream = httpRequest.GetRequestStream()" is causing the delay.</p>

<pre><code>StringBuilder postData = new StringBuilder(100);
postData.Append("param=");
postData.Append("test");
byte[] dataArray = Encoding.UTF8.GetBytes(postData.ToString());

this.httpRequest = (HttpWebRequest)WebRequest.Create("http://myurl.com");

httpRequest.Method = "POST";
httpRequest.ContentType = "application/x-www-form-urlencoded";

httpRequest.ContentLength = dataArray.Length;

this.requestStream = httpRequest.GetRequestStream();

using (requestStream)
    requestStream.Write(dataArray, 0, dataArray.Length);

this.webResponse = (HttpWebResponse)httpRequest.GetResponse();

Stream responseStream = webResponse.GetResponseStream();
StreamReader responseReader = new System.IO.StreamReader(responseStream, Encoding.UTF8);
String responseString = responseReader.ReadToEnd();
</code></pre>

<p>How can I see what causes this? (for instance: DNS lookup? Server not responding?)</p>

<p>Thanks and regards, Koen</p>
