在網頁程序運行需要較長時間運行的時候,ASP.NET Core MVC會出現502 bad gateway請求超時情況。一般默認的超時時間都比較短,我們需要在 web.config 中配置一下。其中 requestTimeout 屬性就是用來設置超時時長的。
服務器環境: Net Core 2.1.15
參考這篇文章: https://www.cnblogs.com/OpenCoder/p/10307882.html , 測試了一下,第三種方法在代碼里設置超時是沒有用的~~~
然后看第2種方法,看本地IIS Express的設定超時時間是23:00:00, 所以在服務器上也設置這個時間.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore requestTimeout="23:00:00" processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>
</configuration>

