我需要确保同步请求保持活动状态超过 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 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);
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)