The remote server returned an error: (417) Expectation failed

Today I did a little demo using the Search API on Twitter. Create a new project and write the following test code directly in the Page_Load of the test page.

     protected void Page_Load(object sender, EventArgs e)
string urlPost = "";

string postData = "q=twitterapi";
UTF8Encoding encoding = new UTF8Encoding();
byte[] byteData = encoding.GetBytes(postData);

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlPost);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteData.Length;

Stream requestStream = request.GetRequestStream();
requestStream.Write(byteData, 0, byteData.Length);

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Stream receiveStream = response.GetResponseStream();

StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);

Response.Write("Response stream received.");

Unfortunately, The error “The remote Server has returned an Error: (417) taught failed” appeared.
At first, I thought it was the “great Firewall”, but it was still the same after connecting to THE VPN, so I went online to find a solution, and finally I found the reason.
“This error can be caused by a client network environment (Don’t Support “100 continue”). Add the following to the program’s configuration file and give it a try.” The original address:

<servicePointManager expect100Continue="false" />

Test, success!!

Reproduced in:

Read More: