WebRequest超时错误

时间:2011-06-16 12:36:07

标签: windows mono timeout webrequest

我尝试使用“Mono 2.10.2”设置在Mono中构建应用程序,但出现以下错误。

Unhandled Exception: System.Net.WebException: The request timed out
  at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00046] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6.7\mcs\class\System\System.Net\HttpWebRequest.cs:813
  at System.Net.HttpWebRequest.GetResponse () [0x0000e] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6.7\mcs\class\System\System.Net\HttpWebRequest.cs:825

造成此问题的代码是:

string url = "http://webFarm/config.prop"; 
WebRequest req = WebRequest.Create(url); 
WebResponse resp = req.GetResponse(); 

立刻失败了。但是,如果我将设置切换为“默认运行时”而不是“单声道2.10.2”,一切正常。任何人都可以帮我这个吗?

此致 大卫

1 个答案:

答案 0 :(得分:0)

我也使用代码收到此错误:

HttpWebRequest objRequest = 
(HttpWebRequest)WebRequest.Create("https://api-3t.sandbox.paypal.com/nvp");
objRequest.Timeout =15000;
objRequest.Method = "POST";
objRequest.ContentLength = strPost.Length;
using (StreamWriter myWriter = new 
    StreamWriter(objRequest.GetRequestStream()))
            myWriter.Write(strPost);

在GetRequestStream()中导致异常:

System.Net.WebException: The request timed out
  at System.Net.HttpWebRequest.GetRequestStream () [0x0005f] in 
/usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System/System.Net/HttpWebRequest.cs:752
  at NVPAPICaller.HttpCall (System.String NvpRequest) [0x00000] in <filename 

未知&GT;:0

--------------------------------------------------------------------------------
Version information: Mono Runtime Version: 2.10.2 (tarball Mon Apr 18 

18:57:39 UTC 2011); ASP.NET版本:2.0.50727.1433

您应该恢复到较旧的Mono 2.10,2.1.1可能会有效。