为什么Visual Studio Code在ubuntu上启动127.0.0.1而不是localhost

时间:2018-08-05 23:41:26

标签: ubuntu visual-studio-code asp.net-core-mvc

我已经在Ubuntu 18.04和Visual Studio代码版本:1.25.1上安装了.net core 2.1.300-rc1-008673。

我用Visual Studio Code创建了一个项目MVC,当我启动它时,它从运行,并出现以下错误:“您的连接不是私有的。攻击者可能试图从127.0.0.1窃取您的信息”,但是如果我更改将127.0.0.1转换为localhost一切正常。

如果在program.cs中有此命令,我不知道为什么要从127.0.0.1开始:

            WebHost.CreateDefaultBuilder(args)
            .UseKestrel(option => 
            {
                option.Listen(IPAddress.Loopback, 5000);
                option.Listen(IPAddress.Loopback, 5001, listenOptions =>
                {
                    listenOptions.UseHttps("localhost.pfx", "lolo");
                });
            })
            .UseStartup<Startup>();

我想并希望初始URL是。

我怎么说VisualStudioCode从本地主机运行项目?

谢谢。

1 个答案:

答案 0 :(得分:0)

保证127.0.0.1可以回送,而localhost则受dns覆盖。