2017-10-09 106 views
0

如果我在本地运行我的应用程序(使用本地主机),它可以很好地工作。为什么我的前端不从我的后端检索信息?

但是,当我决定切换到我的全球IP地址(当我说全球我的意思不是我的LAN 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

而且我已经在我的路由器和防火墙中打开了端口。

现在,在我的路由器中,我只打开了端口:45510764714​​,因为这是在我的前端运行的端口,而在我的后端运行的是52889

我该做什么错?

+0

可能尝试改变这个'--host 0.0 .0.0'到'--host my-isp' –

+0

我已经试过了,它说ip不能被绑定。 – RottenCheese

回答

0

解决方案: 我改变:

<bindings> 
    <binding protocol="http" bindingInformation="*:52899:localhost" /> 
    <binding protocol="http" bindingInformation="*:52899:my-isp-ip" /> 
</bindings> 

要:

<bindings> 
    <binding protocol="http" bindingInformation="*:52899:localhost" /> 
    <binding protocol="http" bindingInformation="*:52899:*" /> 
</bindings> 

而且运行Visual Studio作为管理员...

相关问题