Showing posts with label requestTimeout. Show all posts
Showing posts with label requestTimeout. Show all posts

Increase request timeout of ASP.NET Core API hosted in Azure App Service

If you are using ASP.NET Core 2.0 API and deploying to an Azure App Service, and if the process takes more than 2 minutes, then you will get 502 Bad Gateway response with the message "The specified CGI application encountered an error and the server terminated the process".

You can fix this by adding web.config file to your project -> uncomment <system.webServer> block and add requestTimeout="00:20:00" as shown below

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!-- To customize the asp.net core module uncomment and edit the following section. 
  For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
  
  <system.webServer>
    <handlers>
      <remove name="aspNetCore"/>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" requestTimeout="00:20:00"/>
  </system.webServer>
    
</configuration>

Happy Coding  😊!!