【发布时间】:2024-01-07 14:58:01
【问题描述】:
如果我在本地(使用 localhost)运行我的应用程序,它可以完美运行。
但是当我决定切换到我的全球 IP 地址时(当我说全球时,我的意思不是我的局域网 IP 地址,而是我的 ISP 提供的那个)。
它只是不从我的后端加载数据。
这就是我从前端发出请求的方式:
this.http.get("http://my-isp-ip:52899/api/Student/ListStudents").subscribe(response => {
this.users = response["Users"];
});
这就是我在后端获取 applicationhost.config 的方式:
<bindings>
<binding protocol="http" bindingInformation="*:52899:localhost" />
<binding protocol="http" bindingInformation="*:52899:my-isp-ip" />
</bindings>
我像这样运行前端应用程序:
ng serve --host 0.0.0.0
而且我已经在路由器和防火墙中打开了端口。
现在,在我的路由器中,我只打开了以下端口:4200,因为这是在我的前端运行的端口,而52889 是在我的后端运行的端口。
我做错了什么?
【问题讨论】:
-
可以试试把
--host 0.0.0.0改成--host my-isp -
我已经试过了,它说那个ip无法绑定。
标签: networking asp.net-web-api angular4-httpclient