I am experiencing a request timeout from IIS when I run a long operation. Behind the scene my ASP.NET application is processing data, but the number of records being processed is large, and thus the operation is taking a long time.
However, I think IIS times out the session. Is this a problem with IIS or ASP.NET session?
Thanks in advance
Great and exhaustive answerby @Kev!
Since I did long processing only in one admin page in a WebForms application I used the code option. But to allow a temporary quick fix on production I used the config version in a
<location>
tag in web.config. This way my admin/processing page got enough time, while pages for end users and such kept their old time out behaviour.Below I gave the config for you Googlers needing the same quick fix. You should ofcourse use other values than my '4 hour' example, but DO note that the session
timeOut
is in minutes, while the requestexecutionTimeout
is in seconds!And - since it's 2015 already - for a NON- quickfix you should use .Net 4.5's async/await now if at all possible, instead of the .NET 2.0's ASYNC page that was state of the art when KEV answered in 2010 :).
I'm posting this here, because I've spent like 3 and 4 hours on it, and I've only found answers like those one above, that say do add the
executionTime
, but it doesn't solve the problem in the case that you're using ASP .NET Core. For it, this would work:At web.config file, add the
requestTimeout
attribute ataspNetCore
node.In this example, I'm setting the value for 10 minutes.
Reference: https://docs.microsoft.com/en-us/aspnet/core/hosting/aspnet-core-module#configuring-the-asp-net-core-module
If you want to extend the amount of time permitted for an ASP.NET script to execute then increase the
Server.ScriptTimeout
value. The default is 90 seconds for .NET 1.x and 110 seconds for .NET 2.0 and later.For example:
This value can also be configured in your
web.config
file in thehttpRuntime
configuration element:Please note according to the MSDN documentation:
If you've already done this but are finding that your session is expiring then increase the ASP.NET
HttpSessionState.Timeout
value:For example:
This value can also be configured in your
web.config
file in thesessionState
configuration element:If your script is taking several minutes to execute and there are many concurrent users then consider changing the page to an Asynchronous Page. This will increase the scalability of your application.
The other alternative, if you have administrator access to the server, is to consider this long running operation as a candidate for implementing as a scheduled task or a windows service.
Remove
~
character in location sobecomes