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.
Hey, that's aweomse! This was the first thing I learned today - Thanks!
ReplyDeleteaweomse? is that a dyslexic "awesome"? You are forgiven, my son. Thanks for the compliment :-)
ReplyDeleteGreat 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