Asp.net core 3.1 + Angular DNS Lookup Error - 前端和后端无法通信

问题描述 投票:0回答:1

我用Angular新建了一个Asp.net Core 3.1,使用默认模板,刚按F5执行。

恢复npm包后,应用程序没有正确启动,前台和后台无法通信。

Visual Studio的启动时间是 https:/localhost:5001。 (ASP.NET API),它应该重定向到 http:/localhost:60433 但我没有打开Hello World页面,而是收到了这个 504 DNS查询失败 错误。

enter image description here

如果我打开 http:/localhost:60433 它打开Hello World页面,它由 ng serve. 但是调用API(在localhost:5001)不工作。所以无法登录或使用Fetch Data(它调用API的WeatherForecast方法)。

enter image description here

但如果我打开 https:/localhost:5001WeatherForecast。 (在我把 [Authorize] 在控制器中,它的工作!

enter image description here

同样的项目在我家能用,但在我的公司却失败了。也许是我的网络问题,但我不知道从哪里开始找。

有人对这种行为有什么想法吗?

angular visual-studio templates asp.net-core iis-express
1个回答
0
投票

你可以试试下面的方法。

  1. 在命令提示符下运行这个命令 nslookup. https:/localhost:5001。

  2. 一个解决方案是将上面这个url添加到C:/Windows/System32/Drivers/etchosts文件中。

    打开你的hosts文件,并在那里添加这行127.0.0.1。 https:/localhost:5001。

© www.soinside.com 2019 - 2024. All rights reserved.