ASP.NET CORE
var app = WebApplication.CreateBuilder(args).Build(); RequestDelegate handler = context => { Console.WriteLine("123"); return context.Response.WriteAsync("hello "); }; app.Run(handler); app.Run();
输出 123 两次
是浏览器请求了2次(其中1次请求了/favicon.ico
),详见 Why are Middleware Components Called Twice in a .Net Core Pipeline?
用 curl 命令请求可以验证