What is the Expect100Continue property in System.Net.ServicePointManager?

4

I'm working on a system that manages the licenses of customers.

There is a feature on my system to return the customer's product key by querying 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 the message of 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 setting value as falso , which can be done by the configuration file or in the code snippet before querying through the Web Service.

Code

System.Net.ServicePointManager.Expect100Continue = false; 

Configuration

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

Can anyone tell me what this is for?

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

    
asked by anonymous 29.03.2016 / 20:25

1 answer

4

Code 100 is an HTTP protocol status.

Its purpose is to allow a client, before sending the contents of a request to the server, to send the headers so that the server can determine 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 very large, the server receives the request and then rejects it without even looking at the content.

In .NET, specifying that you will not be using this behavior (Expect100Continue = false), the client already knows that it will not wait for this early response from the server before sending the complete content.

Read the W3C specification for this behavior here: link

    
29.03.2016 / 22:24