1
我正在使用WCF REST 4.0默认端点配置,在客户端上我正在使用WebClient。 无论如何要为WebClient配置新的超时值?WCF REST 4.0 WebClient默认端点设置超时
我正在使用WCF REST 4.0默认端点配置,在客户端上我正在使用WebClient。 无论如何要为WebClient配置新的超时值?WCF REST 4.0 WebClient默认端点设置超时
我已经使用了一个自定义类here。
public class MyWebClient: WebClient
{
//time in milliseconds
private int timeout;
public int Timeout
{
get {
return timeout;
}
set {
timeout = value;
}
}
public MyWebClient()
{
this.timeout = 60000;
}
public MyWebClient(int timeout)
{
this.timeout = timeout;
}
protected override WebRequest GetWebRequest(Uri address)
{
var result = base.GetWebRequest(address);
result.Timeout = this.timeout;
return result;
}
}
一般的想法是重写内部WebRequest的超时。太好了!