日期:2014-05-17  浏览次数:20409 次

有人碰到过webrequest.timeout设置无效的问题吗?
C# code

  protected static string GetHttpData(string url)
    {
        StreamReader sr = null;
        string str = "";
        try
        {
            WebRequest temp = WebRequest.Create(url);
            temp.Timeout = 1000;
            //读取

            WebResponse myTemp = temp.GetResponse();
            sr = new StreamReader(myTemp.GetResponseStream(), System.Text.Encoding.GetEncoding("gb2312"));
            str = sr.ReadToEnd();
        }
        catch
        {
            return "-1";
        }
        return str;
    }


以上代码,在IIS6中执行,Timeout起作用了,但是在IIS7中无效,求解

------解决方案--------------------
设置temp.Proxy = null