Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The request failed with HTTP status 417: Expectation Failed - Using Web Services

Tags:

some minutes ago i was working on a project in visual studio 2010 and suddenly my pc was restarted.
after rebooting i got the error below when browsing that web site in local machine:

The request failed with HTTP status 417: Expectation Failed.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The request failed with HTTP status 417: Expectation Failed.

my web site's name is : MyWebSite
i have a web service on a remote server (a vps) that MyWebSite is using it and that error is in relationship with it.

Line 172:        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/MyWebSiteEnable", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] Line 173:        public bool MyWebSiteEnable() { Line 174:            object[] results = this.Invoke("MyWebSiteEnable", new object[0]); Line 175:            return ((bool)(results[0])); Line 176:        } 

every thing is ok about that web service.
so what is this error and how can i fix it?
there is just a simple bool method inside that web service that returns true.
and i am using that web servive in code-behind like below :

private void CheckForPageExpiration() {     MyService service = new MyService();     if (service.MyWebSiteEnable())     {     }     else     {         Response.Redirect("~/blank.aspx");     } } 

i removed that web service and add it again, but still have that error!
what is wrong about that?

thanks in advance

like image 491
SilverLight Avatar asked Jun 25 '12 22:06

SilverLight


People also ask

When should I use HTTP 417?

To use the 417 HTTP Status Code is when there is a problem with the server's ability to meet the requirements of the Expect request-header field.

Which HTTP status code is reserved for client errors?

Successful responses ( 200 – 299 ) Redirection messages ( 300 – 399 ) Client error responses ( 400 – 499 ) Server error responses ( 500 – 599 )


1 Answers

This suggests that the problem is a proxy server that does not support a 100-continue response from the server, and shows code for resolving it. This would explain why it works on another network.

Since you are unlikely to convince your ISP to change their practice (no harm in a request though), you should turn off the behavior of sending a 100-Continue as the link suggests by either:

Putting this code before an web request:

System.Net.ServicePointManager.Expect100Continue = false; 

Or, adding the following lines to the applications configuration file as a child of the <configuration> tag:

<system.net>     <settings>         <servicePointManager expect100Continue="false" />     </settings> </system.net> 
like image 165
Michael Avatar answered Sep 22 '22 09:09

Michael