代码如下:            // Prepare web myRequestuest...  
            HttpWebRequest mymyRequestuest = (HttpWebRequest)WebRequest.Create(address);
            mymyRequestuest.Method = "GET";
            // mymyRequestuest.ContentLength = 1000;
            mymyRequestuest.Accept = "*/*";
            mymyRequestuest.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; QQPinyin 722; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; InfoPath.2)";
            mymyRequestuest.KeepAlive = true;
            mymyRequestuest.Referer = Config.chj_List;
            mymyRequestuest.ContentType = "text/html";            //初始化cookie
            mymyRequestuest.CookieContainer = new CookieContainer();
            mymyRequestuest.CookieContainer = cookieContainer;            HttpWebResponse res = (HttpWebResponse)mymyRequestuest.GetResponse();平时运行的时候都会超时,但是如果我把Fiddle软件(一个监测电脑HTTP协议的软件)打开的话,程序会运行的非常好,也不会出现超时的问题。我不知道问题到底出在哪里?求高手解决。

解决方案 »

  1.   

    通过:
    System.Net.ServicePointManager.DefaultConnectionLimit = 50;
    而解决了此问题,详情参考:【已解决】HttpWebRequest的GetResponse偶尔超时
    http://www.crifan.com/2012/02/16/fixed_problem_sometime_httpwebrequest_getresponse_timeout/
      

  2.   

    垃圾csdn不能改上面的我自己的帖子。
    上面地址已变为:
    【已解决】HttpWebRequest的GetResponse偶尔超时
    http://www.crifan.com/fixed_problem_sometime_httpwebrequest_getresponse_timeout/