Hi AG,
I have tried researching your problem and recreate it with the provided code. Here are the things that you might need to consider when setting timeout:
1. Update web.config for ASP.NET Core Module (ANCM)
If the app is hosted in-process on IIS, ANCM has a default request timeout of 2 minutes. You need to extend it by changing the web.config file:
<aspNetCore processPath="dotnet"
arguments=".\<your_project_name>.dll"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout"
hostingModel="inprocess"
requestTimeout="00:15:00" />
You can check out the web.config requestTimeout attribute configuration here: web.config file | Microsoft Learn
2. Check IIS Application Pool Settings
Even if the connection timeout is set to 900 seconds, you should consider changing other IIS settings like max request body size, header size, or execution timeout.
In IIS Manager:
- Go to Application Pools → Your App Pool → Advanced Settings
- Set:
- Ping Maximum Response Time =
900
seconds- Shutdown Time Limit =
900
seconds - Idle Timeout =
0
(or a high value)
- Shutdown Time Limit =
These might prevent IIS from shutting down the app pool too early.
3. Middleware problem
Since your timeout logic already handles Status408RequestTimeout
, it's likely that the request is failing before it even reaches that part of your code.
If possible, could you also share a segment of the IIS logs from your test? That might help pinpoint where the request is getting dropped or why the 400 Bad Request
is being returned before your timeout logic kicks in.
Please let me know if my solutions help in anyway, as I will try to research this problem as you give me more information.