我通过以下方式创建了一个基本的 Asp.net core 2.0 Web 应用程序:
新应用程序 => ASP.Net Core Web 应用程序 => Web 应用程序 =>
(MVC) => 更改身份验证 => 个人用户帐户(启用 docker)
调试这个会给你这个:
如果你去掉 https://localhost:44360/
,这显然会给你一个 404。然后应用程序在那里调试。我见过this answer ,但这对我不起作用。
我创建了一个 hosting.json
正如答案所建议的那样:
{
"server": "Microsoft.AspNetCore.Server.Kestrel",
"server.urls": "http://localhost:4000"
}
我将此添加到
Configure()
启动方法:var config = new ConfigurationBuilder()
.AddJsonFile("/app/hosting.json", optional: false)
.AddEnvironmentVariables(prefix: "ASPNETCORE_")
.Build();
var host = new WebHostBuilder()
.UseConfiguration(config)
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
这并没有解决我的启动问题。我做错了什么或者我需要做什么来解决这个调试问题?
最佳答案
在创建新项目并使用 Visual Studio Community 2017 安装适用于 Windows 的 Docker 后,我看到了同样的问题。
似乎 docker-compose 属性页有一个错误的服务 URL 属性,在我的情况下生成为:http://localhost:{ServicePort}/https://localhost:44339/
要解决此问题:
docker-compose
项目Properties
Service URL
与:http://localhost:{ServicePort}
关于docker - 使用 docker 的 asp.net core 的默认应用程序以两个启动 url 开头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46386716/