WebService超时设置

[亡魂溺海] 提交于 2020-03-08 20:01:13

1. 服务器端设置超时

在 web.config 的 system.web 里添加如下配置项:

< httpRuntime
executionTimeout="30"
/>

以上时间单位是秒.

记得要把 web.config 的 debug 模式关闭:

< compilation
defaultLanguage="c#"
debug="false"
/>

2. 客户端设置超时

在 WebService 的客户端代理程序(用 wsdl.exe 生成)里设置 Request 超时时间, 单位是毫秒:
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest wr = (HttpWebRequest)base.GetWebRequest( uri );
wr.Timeout = 30*1000;
return wr;
}


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!