// See https://aka.ms/new-console-template for more information using System.Net; using Microsoft.AspNetCore.Connections; Console.WriteLine("Hello, World!"); var host = Host.CreateDefaultBuilder() //.ConfigureLogging(logging => //{ // logging.ClearProviders(); // 清除默认日志提供者(可选) // logging.AddProvider(new LoggerProvider(logger)); // 添加自定义日志提供者 //}) .ConfigureWebHostDefaults(webBuilder => { webBuilder .UseUrls() //消除警告 Microsoft.AspNetCore.Server.Kestrel[0] Overriding address(es) 'https://localhost:5001/, http://localhost:5000/'. Binding to endpoints defined via IConfiguration and/or UseKestrel() instead. //.Configure(app => //{ // // 防止启动时报错 No application configured // // 没用🙄 无法取消日志 No action descriptors found. This may indicate an incorrectly configured application or missing application parts. To learn more, visit https://aka.ms/aspnet/mvc/app-parts // //app.Use(async (HttpContext context, RequestDelegate next) => context.Response.WriteAsync("Hello from Kestrel!")); //}) .UseKestrel(kop => { kop.Listen(new IPEndPoint(IPAddress.Any, 8000), lop => lop.Use( async (ConnectionContext context, ConnectionDelegate next) => await connectionHandler(context) ) ); }); }) .Build(); await host.StartAsync(); static async Task connectionHandler(ConnectionContext connectionContext) { throw new NotImplementedException(); }