bad performance for the code to send Http request
I am new to Http in C#. Here is my code segment. My performance test result is 1st time it takes long time, almost 30 seconds, and from the 2nd time to the 10th time, it takes very little time (expected).
TestBlade is a machine which is located in local LAN. I have tried with IE, very quick response each time.
Any ideas why 1st time is so slow?
Uri server = new Uri("http://TestBlade:8080/monitor");
WebClient myWebClient = new WebClient();
// open file to read
int counter = 10;
Console.WriteLine("Testing TestBlade performance... ");
while (counter > 0)
// post data
Console.WriteLine("Round " + counter + " Begin time: " + DateTime.Now);
returnRawBytes = myWebClient.UploadData(server.AbsoluteUri, System.Text.Encoding.ASCII.GetBytes("Hello server"));
Console.WriteLine("Round " + counter + " Complete time: " + DateTime.Now);
catch (Exception e) // get any other error