在网页程序运行需要较长时间运行的时候,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>
posted on 2019-07-24 12:06  Gu  阅读(1772)  评论(0编辑  收藏  举报