我需要確保同步請求保持活動狀態超過 60 分鐘。有沒有辦法更改 DotNet 6 中的默認入站請求超時?
我找到了這個:
serverOptions.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(60);
https://docs.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();
uj5u.com熱心網友回復:
根據您的描述,我建議您可以嘗試通過更改 program.cs 檔案代碼來修改它:
更多細節,您可以參考以下代碼:
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseKestrel(options =>
{
options.Limits.MaxConcurrentConnections = 100;
options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(60);
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/404837.html
標籤:
