c# – 无法连接远程服务器(Web服务)

前端之家收集整理的这篇文章主要介绍了c# – 无法连接远程服务器(Web服务)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图将这个Web服务集成到我的asp.net项目中,但它会弹出这种类型的错误!如果您对此有任何想法,请给我解决方案.有很多关于oodle web服务和oodle API的材料.

尝试使用此URL可以更好地了解我的问题
http://api.oodle.com/api/v2/listings?key=TEST&region=chicago&category=vehicle/car

解决方法

try
    {
        string url = @"http://api.oodle.com/api/v2/listings?key=TEST&region=chicago";

        WebClient webClient = new WebClient();
        webClient.Encoding = Encoding.UTF8;
        string result = webClient.DownloadString(url);

       }
  catch (Exception ex)
    {
        Response.Write(ex.ToString());

    }

该语句创建异常

string result = webClient.DownloadString(url);

和例外细节是

System.Net.WebException: Unable to connect to the remote server ---> 
System.Net.Sockets.SocketException: A connection attempt Failed because the connected 
party did not properly respond after a period of time,or established connection Failed 
because connected host has Failed to respond 192.168.0.101:808 at 
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,SocketAddress 
socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure,Socket s4,Socket s6,Socket& socket,IPAddress& address,ConnectSocketState state,IAsyncResult asyncResult,Int32 timeout,Exception& exception) --- End of inner exception 
stack trace --- at System.Net.WebClient.DownloadDataInternal(Uri address,WebRequest& 
request) at System.Net.WebClient.DownloadString(Uri address) at 
System.Net.WebClient.DownloadString(String address) at _Default.lnkGoTo_Click(Object 
sender,EventArgs e) in d:\MyDemoz\oodleDemo\Default.aspx.cs:line 58

猜你在找的C#相关文章