Is is possible to set the "aspNetCore requestTimeout" value (see xml below).........via "code" with Kestrel?
I cannot find something on the KestrelServerLimits object.
Below is the xml code..........but hoping to do this in CODE, not via (published) xml.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore requestTimeout="00:20:00" processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>
</configuration>
I tried the below (" serverOptions.Limits.KeepAliveTimeout = TimeSpan.FromSeconds(5); ")......but this does not control the server timeout from my postman tests.
namespace MyStuff
{
using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.ConfigureKestrel(serverOptions =>
{
serverOptions.Limits.KeepAliveTimeout = TimeSpan.FromSeconds(5);
});
});
}
}
I've been reading from this microsoft article:
Kestrel options The Kestrel web server has constraint configuration options that are especially useful in Internet-facing deployments.
Set constraints on the Limits property of the KestrelServerOptions class. The Limits property holds an instance of the KestrelServerLimits class.