执行下面代码时出现的出错提示:
HttpWebRequest oRequest = (HttpWebRequest)WebRequest.Create("http://www.baidu.com");
HttpWebResponse oResponse = (HttpWebResponse)oRequest.GetResponse();
请问要怎么解决这个问题?谢谢

解决方案 »

  1.   

    “/WebApplication1”应用程序中的服务器错误。
    --------------------------------------------------------------------------------基础连接已经关闭: 无法连接到远程服务器。 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Net.WebException: 基础连接已经关闭: 无法连接到远程服务器。源错误: 
    行 61:  HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(URL); 
    行 62:  // Sends the HttpWebRequest and waits for the response.            
    行 63:  HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); 
    行 64:  // Gets the stream associated with the response.
    行 65:  Stream receiveStream = myHttpWebResponse.GetResponseStream();
     源文件: c:\inetpub\wwwroot\webapplication1\webform1.aspx.cs    行: 63 
      

  2.   

    在“控制台应用程序”下执行没有问题,但在“ASP.NET WEB 应用程序”下就报上述的错误。