How to increase executionTimeout for a long-runnin

2020-01-24 21:03发布

In my application, one query takes 3 minutes to execute. I found that Default ExecutionTimeout value is 110 sec.I tried to change this to 500 (seconds) but it didn't fix my problem. Somewhere I found that setting <compilation debug="false"> allows the ExecutionTimeout property to be configured. However, even this didn't solve my problem.

Does anyone know how I can increase the execution timeout for a long-running query?

标签: c# asp.net
6条回答
爷、活的狠高调
2楼-- · 2020-01-24 21:39

To set timeout on a per page level, you could use this simple code:

Page.Server.ScriptTimeout = 60;

Note: 60 means 60 seconds, this time-out applies only if the debug attribute in the compilation element is False.

查看更多
ら.Afraid
3楼-- · 2020-01-24 21:40

in my case, I need to have my wcf running for more than 2 hours. Setting and did not work at all. The wcf did not execute longer than maybe 20~30 minutes. So I changed the idle timeout setting of application pool in IIS manager then it worked! In IIS manager, choose your application pool and right click on it and choose advanced settings then change the idle timeout setting to any minutes you want. So, I think setting the web.config and setting the application pool are both needed.

查看更多
可以哭但决不认输i
4楼-- · 2020-01-24 21:41

You can set executionTimeout in web.config to support the longer execution time.

executionTimeout specifies the maximum number of seconds that a request is allowed to execute before being automatically shut down by ASP.NET. MSDN

<httpRuntime  executionTimeout = "300" />

This make execution timeout to five minutes.

Optional Int32 attribute.

Specifies the maximum number of seconds that a request is allowed to execute before being automatically shut down by ASP.NET.

This time-out applies only if the debug attribute in the compilation element is False. Therefore, if the debug attribute is True, you do not have to set this attribute to a large value in order to avoid application shutdown while you are debugging. The default is 110 seconds, Reference.

查看更多
趁早两清
5楼-- · 2020-01-24 21:50

RE. "Can we set this value for individual page" – MonsterMMORPG.

Yes, you can (& normally should) enclose the previous answer using the location-tag.

e.g.

  ...
  <location path="YourWebpage.aspx">
    <system.web>
      <httpRuntime executionTimeout="300" maxRequestLength="29296" />
    </system.web>
  </location>
</configuration>

The above snippet is taken from the end of my own working web.config, which I tested yesterday - it works for me.

查看更多
倾城 Initia
6楼-- · 2020-01-24 22:01

Execution Timeout is 90 seconds for .NET Framework 1.0 and 1.1, 110 seconds otherwise.

If you need to change defult settings you need to do it in your web.config under <httpRuntime>

<httpRuntime executionTimeout = "number(in seconds)"/>

But Remember:

This time-out applies only if the debug attribute in the compilation element is False.

Have look at in detail about compilation Element

Have look at this document about httpRuntime Element

查看更多
▲ chillily
7楼-- · 2020-01-24 22:03

When a query takes that long, I would advice to run it asynchronously and use a callback function for when it's complete.

I don't have much experience with ASP.NET, but maybe you can use AJAX for this asynchronous behavior.

Typically a web page should load in mere seconds, not minutes. Don't keep your users waiting for so long!

查看更多
登录 后发表回答