请求失败,HTTP状态417:期望失败 - 使用Web服务 [英] The request failed with HTTP status 417: Expectation Failed - Using Web Services

查看:1082
本文介绍了请求失败,HTTP状态417:期望失败 - 使用Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几分钟前,我正在开展视觉工作室2010的项目,突然我的电脑重新启动。

重新启动后,我在本地机器上浏览该网站时收到以下错误信息:


请求失败,HTTP状态417:期望失败。



说明:在执行
当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误的更多
信息及其在代码中的位置。



异常详细信息:System.Net.WebException:请求失败
HTTP状态417:期望失败。


我的网站的名称是: MyWebSite

i在MyWebSite正在使用的远程服务器(vps)上具有Web服务,并且该错误与其关联。第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)] 
行173:public bool MyWebSiteEnable(){
行174:object [] results = this.Invoke(MyWebSiteEnable,new object [0]);
行175:return((bool)(results [0]));
行176:}

关于该Web服务的一切都可以。

那么这个错误是什么,我该如何解决?

这个web服务中只有一个简单的bool方法返回true。

我正在使用该web在代码隐藏中服务如下:

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

我删除了该Web服务并重新添加,还有这个错误!

有什么问题吗?



提前感谢

解决方案

这个表明问题是代理服务器不支持来自服务器的100连续响应,并显示解决它的代码。这将解释为什么它在另一个网络上工作。



由于您不太可能说服您的ISP更改其实践(在请求中没有损害),您应该关闭发送一个100-Continue的行为是链接建议的:



将此代码放在网络请求之前:

  System.Net.ServicePointManager.Expect100Continue = false; 

或者,将以下行添加到应用程序配置文件中,作为< configuration> 标签:

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


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>

这篇关于请求失败,HTTP状态417:期望失败 - 使用Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆