0

这是代码:

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddControllers();

var app = builder.Build();

Thread.Sleep(10000);

// Configure the HTTP request pipeline.

app.UseAuthorization();

app.MapControllers();

app.Run();

我添加到模板生成代码中的唯一内容是 10 秒延迟。现在使用 Ctrl+F5 运行此代码,出现错误:'无法连接到 Web 服务器 [我的项目名称]'

错误

我尝试了 8 秒,它成功启动。那么这种行为背后的机制是什么?是否可以配置某种超时选项以允许长期项目启动?

注意:这只发生在使用 Kestrel 的默认启动时。更改为使用 IIS Express 启动可以允许至少 10 秒的延迟。

4

0 回答 0