How to increase executionTimeout for a long-running query?
C#asp.netC# Problem Overview
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# Solutions
Solution 1 - C#
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
Solution 2 - C#
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.
Solution 3 - C#
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.
Solution 4 - C#
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.
Solution 5 - C#
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!
Solution 6 - C#
in my case, I need to have my wcf running for more than 2 hours. Setting