.NET Core 修改程序默认监听端口

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
            .UseWindowsService()
            .UseContentRoot(AppContext.BaseDirectory)
            .ConfigureServices((hostContext, services) =>
            {
                services.AddHostedService<Worker>();
            })
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup<Startup>().UseKestrel(opt =>
                {
                    //opt.ListenLocalhost(5088); 本地监听
                    opt.ListenAnyIP(5088);
                });
            }).ConfigureLogging((context, logging) =>
            {
                logging.ClearProviders();
                logging.AddConsole();
                logging.SetMinimumLevel(LogLevel.Trace);
            }).UseNLog();
 
posted @ 2021-10-29 15:06  _Tbz  阅读(220)  评论(0编辑  收藏  举报