M
matt
hello,
i am using a .NET 1.1 winform to perform webrequests via the
System.Net.WebClient class. It uploads values via a POST command & a
URL, then receives the html back. nothing too complicated there.
except, i am frequently getting the dreaded error:
The underlying connection was closed: an unexpected error occurred
on a receive
....which after some googling, appears to be a .NET bug w/ regards to
open connections actually being closed. this error is typically run
into while working w/ ASP.NET webservers and/or webservices.
i have found many articles instructing one to disable keep-alives, and
using HTTP version 1.0. doing so in this method from the "reference.cs"
seems common:
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = (HttpWebRequest)
base.GetWebRequest(uri);
webRequest.KeepAlive = false;
webRequest.ProtocolVersion=HttpVersion.Version10;
return webRequest;
}
....however, i dont know what this "reference.cs" file is.
can anyone provide me w/ the following clues:
- how can i have my WebClient object use a custom WebRequest like the
above?
- can i somehow set the keepalive & http version via the
WebClient.Headers collection?
- is this bug perhaps fixed in .NET 2.0 ?
any help would be appreciated!
thanks,
matt
i am using a .NET 1.1 winform to perform webrequests via the
System.Net.WebClient class. It uploads values via a POST command & a
URL, then receives the html back. nothing too complicated there.
except, i am frequently getting the dreaded error:
The underlying connection was closed: an unexpected error occurred
on a receive
....which after some googling, appears to be a .NET bug w/ regards to
open connections actually being closed. this error is typically run
into while working w/ ASP.NET webservers and/or webservices.
i have found many articles instructing one to disable keep-alives, and
using HTTP version 1.0. doing so in this method from the "reference.cs"
seems common:
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = (HttpWebRequest)
base.GetWebRequest(uri);
webRequest.KeepAlive = false;
webRequest.ProtocolVersion=HttpVersion.Version10;
return webRequest;
}
....however, i dont know what this "reference.cs" file is.
can anyone provide me w/ the following clues:
- how can i have my WebClient object use a custom WebRequest like the
above?
- can i somehow set the keepalive & http version via the
WebClient.Headers collection?
- is this bug perhaps fixed in .NET 2.0 ?
any help would be appreciated!
thanks,
matt