c# Multiple WebRequest and WebResponse timeout problems.


Hi Everyone ,

In this tips and tricks article i wanna talk about when we use Multiple WebRequest object for interacting some urls getting timeout errors even if remote server not busy.
this is usually caused by not dispose some open WebResponse objects.You can also use “using” statement for disposing unnecessery objects .

For good example :

WebRequest wrGETURL;
wrGETURL = WebRequest.Create(sURL);
// wrGETURL.Proxy = myProxy;

durationTime = DateTime.Now;

using
(HttpWebResponse response = (HttpWebResponse)wrGETURL.GetResponse())
{
status = response.StatusCode.ToString();
TimeSpan ts = DateTime.Now – durationTime;
duration = ts.TotalMilliseconds.ToString();
}

Advertisements

About bpostaci
Escalation Engineer in Microsoft.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: