Expect: 100-Continue

There are many questions on this topic, but ... they did not give me an answer.

As from the tips - you need to set ServicePointManager.Expect100Continue = false . But this is unacceptable, because it will be a module that works asynchronously with a dozen others. Thus, an acceptable solution is a property for each connection. There are tips on how to fix this, but it does not seem to work.

Here is the code:

 var conuri = new Uri(connectionString); var sp = ServicePointManager.FindServicePoint(conuri); sp.Expect100Continue = false; _request = (HttpWebRequest)WebRequest.Create(conuri); _request.ContentType = "text/xml"; _request.Method = "POST"; _request.ContentLength = dataToSend.Length; requestStream = _request.GetRequestStream(); requestStream.Write(dataToSend, 0, dataToSend.Length); 

The problem is that at the point "requestStream.Write" the Expect: 100-continue header is still being added, but it should not follow the advice I read here: C # Expect100Continue request header .

+6
source share
1 answer

You can do it as follows:

 _request.ServicePoint.Expect100Continue = false; 

This will disable Expect: 100-continue for the specific HttpWebRequest instance.

+23
source

All Articles