【问题标题】:IHostBuilder not working while IWebHostBuilder in Linux in aspnet core 3.1 web api applicationIHostBuilder 在 Linux 中的 aspnet 核心 3.1 Web api 应用程序中的 IWebHostBuilder 不工作
【发布时间】:2020-04-04 17:17:52
【问题描述】:

我有 .net core web api 项目。我在 Windows 和 Linux 中运行我的应用程序

问题是我的应用程序使用 IWebHostBuilder 在 linux 和 windows 中启动和工作,而使用 IHostBuilder 的等效代码(我认为是这样)没有在 linux 中启动我的应用程序。

请有人告诉我我做错了什么

以下目前有效

 public static IWebHostBuilder BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args).
            ConfigureKestrel(serverOptions =>
            {
            }).UseIISIntegration()
            .UseStartup<StartupShutdownHandler>();

以下在 linux 中不起作用

public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.ConfigureKestrel(serveroptions => { }).UseIISIntegration().UseStartup<StartupShutdownHandler>();
                });

【问题讨论】:

    标签: startup .net-core-3.1


    【解决方案1】:

    问题出在我的 linux 服务文件中,关于 --service.urls 参数。 我正在使用--service.urls 参数,而推荐的方法是使用--urls。 详情见https://github.com/dotnet/aspnetcore/issues/20566

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-03
      • 2019-09-19
      • 2021-08-14
      • 1970-01-01
      • 2017-06-09
      • 2017-02-10
      • 2022-06-21
      • 1970-01-01
      相关资源
      最近更新 更多