This could be one of the issue you might face while using service call or HTTP Post to server. Though this issue rarely happens but in case you encounter such error in your production, possibility is your client application is facing issue connecting to the server due to proxy server.

 

If you come across such issue, this quick blog post will help you to resolve it. You don’t need to do much, but just a configuration settings will help you.

 

Solution to "The remote server returned an error: (417) Expectation Failed" (www.kunal-chowdhury.com)

 

You might face this issue when a client is running through a HTTP 1.0 proxy server. The client (the .asmx or WCF service proxy without any configuration) is sending a HTTP 1.1 request and the proxy rejects it before any server could ever get involved. Some server sends the 417 error as part of the header in response.

 

In .NET, the System.Net.HttpWebRequest adds the header 'HTTP header "Expect: 100-Continue"' to every request unless you explicitly ask it not to by setting this static property “System.Net.ServicePointManager.Expect100Continue” to false.

 

If you encounter the error “The remote server returned an error: (417) Expectation Failed”, add the following code in you application before the call:

 

System.Net.ServicePointManager.Expect100Continue = false;

 

 

You can also specify that property in your app.config:

 

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

 

 

You can learn more about this settings/properties in MSDN: ServicePointManager.Expect100Continue

 

Hope that the post was useful and helped you to resolve your issue connecting to service. Don’t just stop here. Check out my other blog posts, articles and tips. I am available on Twitter, Facebook and Google+. Do connect with me there to get the latest technical updates that I share. Also, subscribe to my blog’s RSS feed and email newsletter. Happy coding.

 

Have a question? Or, a comment? Let's Discuss it below...

dhgate

Thank you for visiting our website!

We value your engagement and would love to hear your thoughts. Don't forget to leave a comment below to share your feedback, opinions, or questions.

We believe in fostering an interactive and inclusive community, and your comments play a crucial role in creating that environment.