What is the Expect100continue property for in System.Net.Servicepointmanager?

Asked

Viewed 1,524 times

4

I am working on a system that manages customer licenses.

There is a feature in my system to return the customer’s product key , making a query on Web Service.

And simple you inform the CNPJ it returns the a product key.

//Web Service
Gerencial.WebService.WSLicenca ws = new WebService.WSLicenca();

//Key
string ProductKey = ws.RetornaLicenca(CpfCnpj); 

But when performing this operation and displayed the message from Error :

The request failed with HTTP status 417: Expectation failed

According to this article the solution to this problem would be to add the property Expect100continue defining value as falso , which can be done by the configuration file or in the code snippet before the query by the Web Service.

Code

System.Net.ServicePointManager.Expect100Continue = false; 

Setup

 <configuration>
      <system.net>
         <settings>
          <servicePointManager expect100Continue="false" />
         </settings>
        </system.net>
 </configuration>

Can someone tell me what this is for ?

Using this property the bug has been fixed but I have no idea what this property does.

1 answer

4


Code 100 is an HTTP protocol status.

Its purpose is to allow a client, before sending the content (body) of a request to the server, to send the headers (header) so that the server already determines whether or not to accept the complete request.

In some cases it is very inefficient, especially when the content to be sent to the server is too large, the server receive the request and then reject it without even looking at the content.

No. NET, by specifying that it will not be using this behavior (Expect100continue = false), the client already knows that it will not wait for this anticipated response from the server before sending the complete content.

Read here the W3C specification about this behavior: https://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.2.3

Browser other questions tagged

You are not signed in. Login or sign up in order to post.