65

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?

FuriousFolder
  • 1,200
  • 1
  • 12
  • 27
Rakesh Devarasetti
  • 1,409
  • 2
  • 24
  • 42

6 Answers6

122

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

huMpty duMpty
  • 14,346
  • 14
  • 60
  • 99
  • 37
    The tip about the time-out value only applying when debug="true" in the compilation element of the web.config file was excellent. – Ed Graham Jun 17 '13 at 16:25
  • 22
    @EdGraham don't you mean "time-out value only applying when debug=false" ? huMpty duMpty is saying: This time-out applies only if the debug attribute in the compilation element is False – 7wp May 21 '15 at 15:41
  • In azure web app it's possible change this value not upper to 240 seconds. :( – Evilripper Apr 19 '18 at 08:26
29

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.

Adil
  • 146,340
  • 25
  • 209
  • 204
16

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.

Zeek2
  • 386
  • 4
  • 8
  • The way I understand things, could I add a small web.config file to the folder where my specific page is, that just has this setting? I believe the web.configs overload, so that the web.config in the local page folder over-rides the web.config setting at the root, and makes only the specific page more tolerant? – Steve Hibbert Jan 12 '17 at 11:20
  • Steve, I think what you wrote is correct but for me, there was an existing web.config in the folder which contained my .aspx page and I just updated that. Note that the location-tag already provides the functionality to limit this setting to just one, specified .aspx page (to "YourWebpage.aspx" in the example shown) -- I have other .aspx pages in the same folder for which this setting does not apply. – Zeek2 Jul 05 '18 at 11:40
  • This was helpful. Just remember to place httpRuntime outside any authorization elements, else you'll get an error about it. Ask me how I know. – Jeff Mergler May 27 '20 at 15:16
4

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.

Wessam El Mahdy
  • 457
  • 5
  • 14
1

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!

Davio
  • 4,609
  • 2
  • 31
  • 58
  • 4
    executiontimeout is for any request, sync or async... so AJAX requests would suffer from the same time limit –  Sep 29 '16 at 04:47
1

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.

Kevin Yen
  • 78
  • 2
  • 6
  • 1
    It probably means that you did not set it correctly, or did not recycle your app pool after making the change. – Zorgarath Dec 16 '16 at 18:56