加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 08:28:22 所属栏目:百科 来源:网络整理
导读:我试图将这个Web服务集成到我的asp.net项目中,但它会弹出这种类型的错误!如果您对此有任何想法,请给我解决方案.有很多关于oodle web服务和oodle API的材料. 尝试使用此URL可以更好地了解我的问题 http://api.oodle.com/api/v2/listings?key=TESTregion=chic
我试图将这个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:MyDemozoodleDemoDefault.aspx.cs:line 58

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读