asp.net 7 api how to increase timeout?

AG 521 Reputation points
2023-02-09T19:56:39.6366667+00:00

Hi,

I have created an ASP.NET API with .NET version 7 and I would like to ask how to increase timeout when http client is posting or requesting services from my API up from the default 100 seconds? or it is up to the client to set timeout from his end? (like this code)

builder.Services.AddHttpClient("myClient", client =>
{
    client.Timeout = TimeSpan.FromMinutes(5);
});

My API is deployed to self host IIS 10.

Does my API is using Kestrel by default when deployed to IIS? as there is no UseKestrel in Program.cs

Do I have to use Web.config file in order to set timeout like this <aspNetCore requestTimeout="00:05:00" ... ?

Thanks in advanced,

AG

Developer technologies ASP.NET ASP.NET Core
Developer technologies ASP.NET ASP.NET API
0 comments No comments
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-02-09T20:12:03.0833333+00:00

    yes, the client calling your api, must set their timeout (typically 60/90 seconds). you only control the server request timeout, and server initiated api calls.

    if you are using the aspnetcore hosting module, you configure its request timeout in the webconfig. If using kestrel it has it own setting in the appsetting.json, or startup configuration.

    a 100 seconds seems too long. maybe it should be broken into a start request and check status calls.

    3 people found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. AG 521 Reputation points
    2023-02-10T09:58:04.15+00:00

    Thanks Bruce for your help.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.