Reputation: 2970
I need to ensure a synchronous request stay alive for over 60 minutes. Is there a way to change the default inbound request timeout in DotNet 6?
I found this:
serverOptions.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(60);
But not sure where to get serverOptions in my Program.cs
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();
Upvotes: 3
Views: 15815
Reputation: 28257
According to your description, I suggest you could try to modify it by changing the program.cs file codes:
More details, you could refer to below codes:
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseKestrel(options =>
{
options.Limits.MaxConcurrentConnections = 100;
options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(60);
});
Upvotes: 4