按下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 .