gpt4 book ai didi

asp.net-mvc - 更改 DotNet 6 入站请求超时

转载 作者:行者123 更新时间:2023-12-05 03:31:38 31 4
gpt4 key购买 nike

我需要确保同步请求保持事件状态超过 60 分钟。有没有办法更改 DotNet 6 中的默认入站请求超时?

我发现了这个:

serverOptions.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(60);

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel/options?view=aspnetcore-5.0#keep-alive-timeout

但不确定在我的 Program.cs 中从哪里获取 serverOptions

var builder = WebApplication.CreateBuilder(args);

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

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();

app.UseRouting();

app.UseAuthorization();

app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");

app.Run();

最佳答案

根据你的描述,我建议你可以尝试修改program.cs文件代码:

更多细节,你可以引用下面的代码:

var builder = WebApplication.CreateBuilder(args);

builder.WebHost.UseKestrel(options =>
{
options.Limits.MaxConcurrentConnections = 100;
options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(60);
});

关于asp.net-mvc - 更改 DotNet 6 入站请求超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70615783/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com