Saturday, March 24, 2012

System.Net.WebException and server committed a protocol violation

Hi there,

Does anyone knows what causes the System.Net.WebException and server committed a protocol violation and how do I debug it? Sometimes when I send the url request string to the web brower by using theHttpWebRequest andHttpWebResponseand it doesn't have any System.Net.WebException or server committed a protocol violation, but after a couple request sending, I get that error at theHttpWebResponse ,at first I thought because there are too many request sending at once, that's why it causes the System.Net.WebException and the server committed a protocol violation, but after a few minutes waiting and I re-send it again and still have the same error. Does anyone have the same problem that I have? This is the HTTPHandler Class and sending the request string by the url

I google some search and found some article saying that you can create a function to disable thewebRequest.KeepAlive = false;to solve that problem, but I got an error at 'HandlerLibrary.WebRequest(string)': no suitable method found to override, Can someone shows me the right way to fix this issue, thanks

protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = (HttpWebRequest)base.GetWebRequest(uri);

webRequest.KeepAlive = false;
return webRequest;
}

0 comments:

Post a Comment