How to Increase Timeout ASP.NET Core

In this tutorial, we will advise how to increase timeout in Asp.net Core 2/3 or newest Asp.net Core 5. There are many users ask about this questions so we decide to write this tutorial.

When you deploying your Asp.net core application, and it takes process request more than 2 minutes, then you will see this error message:

"The specified CGI application encountered an error and the server terminated the process".

If you check your diagnostic logfile you might see:

020-06-15 08:27:02.232 +00:00 [Error] Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware: An unhandled exception has occurred while executing the request
System.Threading.Tasks.TaskCanceledException: A task was canceled.

No, there is not way to set request timeout in asp.net core hosted in IIS from C# code.

But according to the documentation you can just add web.config to your project and specify this (and other) setting value: Setting the RequestTimeout="00:20:00" on the aspNetCore tag and deploying the site will cause it not to timeout.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore requestTimeout="00:20:00" processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
  </system.webServer>
</configuration>

Important Notes

If a web.config file is present in the project, the file is transformed with the correct processPath and arguments to configure the ASP.NET Core Module and moved to published output.

The transformation doesn’t modify IIS configuration settings in the file. The web.config file may provide additional IIS configuration settings that control active IIS modules. For information on IIS modules that are capable of processing requests with ASP.NET Core apps, see the IIS modules topic.

To prevent the Web SDK from transforming the web.config file, use the IsTransformWebConfigDisabled property in the project file.

Conclusion

That is simple tutorial about how to increase your timeout in Asp.net core. We will explain other interesting tips for you.

If you are looking for fast and secure ASP.NET hosting, you can visit our site at https://www.asphostportal.com. Our fully featured hosting already includes

  • Easy setup
  • 24/7/365 technical support
  • Top level speed and security
  • Super cache server performance to increase your website speed
  • Top 9 data centers across the world that you can choose.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *