简体   繁体   中英

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

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

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>

Add below line of code in your config file.

<system.net>
    <defaultProxy useDefaultCredentials="true" >
    </defaultProxy>
</system.net>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM