Код: Выделить всё
var timeoutSec = builder.Configuration.GetValue("Main:ServiceTimeoutSec");
builder.Services.AddHttpClient((serviceProvider, client) =>
{
var config = serviceProvider.GetRequiredService();
var baseAddress = config["Api:ApiBaseAddress"] ?? "MISSING_BASE_ADDRESS";
client.BaseAddress = new Uri(baseAddress);
// HAS NO EFFECT -> client.Timeout = TimeSpan.FromSeconds(timeoutSec);
})
.AddPolicyHandler(Policy.TimeoutAsync(TimeSpan.FromSeconds(timeoutSec))); // API query timeout
Подробнее здесь: https://stackoverflow.com/questions/796 ... 30-seconds