使用docker的asp.net核心的默认应用程序从两个启动url开始

我通过以下方式创build了一个基本的Asp.net核心2.0 Web应用程序:

新应用程序=> ASP.Net核心Web应用程序=> Web应用程序=>(MVC)=>更改身份validation=>个人用户帐户(启用docker)

debugging这会给你这个:

在这里输入图像说明

这显然会给你一个404,如果你摆脱了https://localhost:44360/那么应用程序正在那里debugging。 我已经看到了这个答案 ,但是这对我并不适用。

我创build了一个hosting.json作为答案build议:

 { "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(); 

这并没有解决我的启动问题。 我在做什么错,或者我需要做什么来解决这个debugging问题?

在使用Visual Studio Community 2017创build新项目并安装Docker for Windows之后,我看到了同样的问题。

看起来docker-compose Property Pages有一个糟糕的服务URL属性,在我的情况下,这个属性是这样生成的: http://localhost:{ServicePort}/https://localhost:44339/

要解决这个问题:

  • 用鼠标右键单击docker-compose项目
  • selectProperties
  • Service URLreplace为: http://localhost:{ServicePort}