I have this code in console application and it runs in a loop
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(search);
request
After adding
request.KeepAlive = false;
request.ProtocolVersion = HttpVersion.Version10;
it works fine..
I found it form this blog post
WebRequest and Unable to read data from the transport connection Error
I just tried the code, looping 10 times to load google.com and it worked for me. Is there something special about search
- perhaps try replacing it with another uri. I did not include findForMatch
- I assume it is not doing anything that would cause the exception.
Try disposing the reader in the finally block of your try catch