By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,353 Members | 1,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,353 IT Pros & Developers. It's quick & easy.

The server committed an HTTP protocol violation

P: n/a
Does anyone have any experience with this problem. I am trying to post
about 20 fields of information to another server using
System.Net.WebClient.UploadData. This works fine for some servers but one
in particular is causing the exception "The underlying connection was
closed: The server committed an HTTP protocol violation" to be thrown.

I found a post that said to add a config file with the following....

<configuration>
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
</configuration>

When I try this, I instead get the exception "An exception occurred during a
WebClient request.". Any ideas?

Thanks,

Dan W.

Nov 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I had this problem, not with webservices or upload, but with a
HttpWebRequest , which is probably at the same layer.

One possible cause is that the server says that it does HTTP 1.1, but it
really does not. So, setting your client-side to HTTP 1.0 might avoid the
problem.
http://msdn.microsoft.com/library/en...mbersTopic.asp

BUT! How do you get access to the underlying HttpVersion from a SOAP
request? Add this code to your generated web reference file (C#):

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

webRequest.KeepAlive = false;
webRequest.ProtocolVersion=HttpVersion.Version10; //
return webRequest;
}

Another possible approach is to just ignore the protocol error. Be careful,
This may or may not result in a correctly functioning app. But, In one case
I had, the protocol error was benign for my purposes.

"Dan W." <dw*******@eadmail.com> wrote in message
news:un****************@TK2MSFTNGP11.phx.gbl...
Does anyone have any experience with this problem. I am trying to post
about 20 fields of information to another server using
System.Net.WebClient.UploadData. This works fine for some servers but one
in particular is causing the exception "The underlying connection was
closed: The server committed an HTTP protocol violation" to be thrown.

I found a post that said to add a config file with the following....

<configuration>
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
</configuration>

When I try this, I instead get the exception "An exception occurred during
a
WebClient request.". Any ideas?

Thanks,

Dan W.

Nov 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.