Archive for January, 2009

VB.Net HttpWebRequest Takes A Long Time On First Request

Wednesday, January 21st, 2009

I have recently been using the HttpWebRequest object in .Net Framework 2 and 3.5. I’m using it to observe the timings of requests on a project and noticed some strange behaviour. The first time you call GetResponse it can take over 30 seconds to return the response, whereas subsequent calls to the same URL will result in much quicker responses. I have found the problem to be in the use of proxies. It tries to find a proxy to use on the first request. To fix this (unless you are using a proxy of course) set the Proxy property to Nothing

request.Proxy = Nothing

By doing this it no longer looks for the default proxy and will speed up requests.


foreandaft