按下API时无法连接到远程服务器 [英] Unable to connect to remote server when hitting an API

查看:478
本文介绍了按下API时无法连接到远程服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面临一个非常奇怪的问题:

I am facing a very weird issue:

案例1:使用ASP.NET Web开发服务器:应用程序点击了API,一切正常.

Case 1: Using ASP.NET Web Development Server: The application hits an API, and everything works fine.

案例2:我将应用程序(MVC)托管在IIS上:当应用程序尝试访问API时,它会收到错误消息:

Case 2: I host my application (MVC) on IIS: When the application tries to hit the API, it gets the error:

无法连接到远程服务器":{连接尝试失败,因为在一段时间后被连接方未正确响应,或者由于连接的主机未能响应96.17.180.160:80而建立的连接失败"}

"Unable to connect to remote server": {"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 96.17.180.160:80"}

代码行:

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(api);
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); // This line breaks...

推荐答案

API中的无法连接到远程服务器",正在发生此错误,因为该项目未在运行您正在调用的项目. 点击时必须运行调用项目. 两个项目必须同时运行.

"Unable to connect to remote server" in API, this error is being occurred because that project is not running which project you are calling. Calling project must be run when you are hitting. Both project must be running at same time .

这篇关于按下API时无法连接到远程服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆