ASP.NET: Prevent Long-Running Page from timing out

On some occasions you may have a database query or other operation that takes a long time. If it takes long enough, your ASP.NET Page may timeout.

Obviously, you want to optimize your SQL or other process, but if you can't you can control the Page Timeout via the httpRuntime element's executionTimeout attribute. You can set the timeout value for a request in web.config. You can even change the timeout for one specific page:

<location path="yourpage.aspx">
<system.web>
<httpRuntime executionTimeout="180"/>
</system.web>
</location>

The httpRuntime element is not explicitly defined in the Machine.config file or in the root Web.config file. However, the following settings are the default values initialized by the system. If you need to customize this section you must create it in your configuration file and define only those attributes that need customization:

<httpruntime
enable="true"
executiontimeout="110"
maxrequestlength="4096"
requestlengthdiskthreshold="256"
usefullyqualifiedredirecturl="false"
minfreethreads="8"
minlocalrequestfreethreads="4"
apprequestqueuelimit="5000"
enablekerneloutputcache="true"
enableversionheader="true"
requirerootedsaveaspath="true"
shutdowntimeout="90"
delaynotificationtimeout="5"
waitchangenotification="0"
maxwaitchangenotification="0"
requestpriority="Normal"
enableheaderchecking="true"
sendcachecontrolheader="true"
apartmentthreading="false"
>

See http://msdn2.microsoft.com/en-us/library/e1f13641.aspx for more details.

Comments

  1. Anonymous10:30 AM

    Hey, that's aweomse! This was the first thing I learned today - Thanks!

    ReplyDelete
  2. aweomse? is that a dyslexic "awesome"? You are forgiven, my son. Thanks for the compliment :-)

    ReplyDelete
  3. Anonymous7:34 PM

    Great and useful info, Peter. I was just working on an image gallery and had some timeouts. Used some of your caching tips from eggheadcafe and will put some of this info to use as well.

    ReplyDelete

Post a Comment

Popular posts from this blog

Some observations on Script Callbacks, "AJAX", "ATLAS" "AHAB" and where it's all going.

IE7 - Vista: "Internet Explorer has stopped Working"

FIREFOX / IE Word-Wrap, Word-Break, TABLES FIX

System.Web.Caching.Cache, HttpRuntime.Cache, and IIS Recycles

FIX: Requested Registry Access is not allowed (Visual Studio 2008)