docker - 使用 docker 的 asp.net core 的默认应用程序以两个启动 url 开头

标签 docker asp.net-core-mvc

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

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

调试这个会给你这个:

enter image description here

如果你去掉 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/

    相关文章:

    bash - 如何在 ENTRYPOINT 等待 postgres 启动?

    asp.net - MVC 6 依赖注入(inject) - 使用或不使用

    node.js - 如何在ubuntu 14.04中将当前环境设置为image docker?

    apache - Docker Apache 安装失败

    linux - 什么是 Docker 存储驱动

    c# - 使用 HttpContext.Features.Get<IHttpConnectionFeature>()?.RemoteIpAddress 时获取 127.0.0.1

    asp.net-core - ASP.NET Core Identity - 扩展密码哈希器

    c# - 具有区域的 ASP.NET Core 2 默认路由

    ASP.NET MVC6 : Setting webroot programmatically

    linux - 如何使用 nohup 让 docker 命令在后台运行