HttpWebRequest super slow

Thursday, August 25, 2011
By keiji
Category: C#, How to
Using HttpWebRequest is quite convenient to access URL.
H/owever, you might have noticed that it sometimes super slow without any apparent reason.
It could take like 10 sec first time to connect, but it works just fine other times.

This seems to be caused by HttpWebRequest's proxy setting.
(Refer to http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.proxy.aspx)

If you do set nothing about it, the default behavior is to use default proxy setting, which try to auto detect proxy server.
This is causing the slowness.

To disable it, just set the "Proxy" property with new WebProxy object as below:

System.Net.ServicePointManager.Expect100Continue = false;
System.Net.ServicePointManager.CheckCertificateRevocationList = false;
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(sURL);
myRequest.Proxy = new WebProxy();

Update August 27, 2011
At some point, the solution setting Proxy didn't solve the issue.
Further research indicated that you might need to change some ServicePointManager's properties. (shown above)

Update August 29, 2011
Well, all these change didn't solve the issue for me, unfortunately.
So, I'm going to use a different method to meat my goal. See my next post.

Comments

N/A

Reply to

Subject:
Name:
E-Mail:
Comment:
(Max 1000 chars)
Confirmation Key:
Please enter the value displayed in the image.
Send Send